Reputation: 3376
I am getting an error message due to an input field I have. It is of type "number" but the actual model is a string. Reason behind this is, that my ngModel value is used in other parts of the application.
However for just one Input Field I need to restrict this as only using numbers.
What is the easiest way to achieve this, without changing the type of ngModel.
Upvotes: 3
Views: 1339
Reputation: 429
Do you can transform string to number:
$scope.age = parseInt(ageString);
At the HTML:
<input type="number" name="age" ng-model="age"/>
Upvotes: 4