How can you limit the value from input using AngularJs?

limit the value from input using AngularJs

We are open to use value or ngValue and the only difference between two is that the “value” is always “string”, where in “ngValue” you can pass “object”.

In the below example, I limited to the age>45 then input field value should beset reset to zero/0 as per my custom scenario. You can update as per your.

Set limit in input field AngularJs -
ng-value="(age > 45 ? age = 0 : age)"


<input type="text" ng-model="age" ng-maxlength="2" ng-pattern="/^[0-9]*$/" ng-value="(age > 45 ? age = 0 : age)"/>


Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog -
My Books - Book 1 and Book 2 Powered by Blogger.