New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular updating value with FormControl produces "value should be string" error #236
Comments
@Valdas3 so you want to get typed nested mask inside Angular. hm.... |
I have same problem with mask 'number'. When I set value to formControl with number value, i got "value should be string". There is other problem: when mask number, value store in model is string, and must be number. |
@odione you have to use |
About original issue. Proposal to do it better way:
|
But mask with blocks not working: export function currencyMask(currencyPrefix = 'R$') {
return {
mask: '${currencyPrefix} number', // enable number mask
lazy: false,
blocks: {
number: {
mask: Number,
scale: 2, // digits after point, 0 for integers
signed: false, // disallow negative
thousandsSeparator: '.', // any single char
padFractionalZeros: true, // if true, then pads zeros at end to the length of scale
normalizeZeros: true, // appends or removes zeros at ends
radix: ',', // fractional delimiter
mapToRadix: ['.'] // symbols to process as radix
}
}
}
} value store in model continues is string and not a number. |
Hi! https://jsfiddle.net/uNmAjs/49ap8v25/ So you use |
I'm having the same You seem to have found the solution in your JSFiddle https://jsfiddle.net/uNmAjs/49ap8v25/ but that example seems a bit out of date as I get Could you update it and explain a bit more how to use it in Angular? Thanks a lot! |
There is a FormControl with a default value which is integer. That FormControl is set on an input which contains an imask with some blocks. This works with no problem but if you try update a value using that FormControl or if you re-create it then IMask throws an error "value should be string". If IMask is a NumberMask then it fails with "unmaskedValue.replace is not a function" error. Should I use some other methods to update the value of a FormControl if the value is integer?
An example which reproduces the issue https://stackblitz.com/edit/angular-imask-uvvy53?file=app%2Fapp.component.ts
The text was updated successfully, but these errors were encountered: