cesarrew / ng2-currency-mask

A very simple currency mask directive that allows using a number attribute with the ngModel.
MIT License
235 stars 116 forks source link

"min" and "max" attributes cannot be set: Type 'string' is not assignable to type 'number'.ngtsc(2322) #173

Open MikhailRatner opened 2 years ago

MikhailRatner commented 2 years ago

I am on Angular 14 and the min and max attributes do not work. Changing the type and inputmode of the input field does not have any effect. The error I get is:

Type 'string' is not assignable to type 'number'.ngtsc(2322)

I am using this on a an input field connected to a FormControl, so via Reactive Forms not Template Driven Forms.

rbedellasmgroup commented 10 months ago

Same issue here. min and max attributes are only supported on input controls with type="number" (and a few other types) but not type="string", which is the default when you don't supply a type and is the type required for currencyMask to work correctly.

Here's an example that will cause this error, and min/max do not work: <input name="customercost" min="0" max="500" [(ngModel)]="cost" matInput required currencyMask />

If I remove currencyMask and change type="number", then min and max work correctly: <input name="customercost" min="0" max="500" [(ngModel)]="cost" matInput required type="number" />