Skip to content
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

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

Open
MikhailRatner opened this issue Jul 26, 2022 · 1 comment

Comments

@MikhailRatner
Copy link

MikhailRatner commented Jul 26, 2022

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
Copy link

rbedellasmgroup commented Oct 30, 2023

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" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants