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

And

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

ANIL SINGH

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 Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.
^