Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
14
rated 0 times [  19] [ 5]  / answers: 1 / hits: 28344  / 10 Years ago, thu, november 13, 2014, 12:00:00

HTML provides a standard maxlength attribute since version 4.01.
Angular provides a ng-maxlength directive.



The difference is that the standard approach doesn't allow entering more than max, while Angular's approach just generates a validation error.



Why did they decide to include such a directive? It's not because of dynamic data binding of maxlength since the behaviour is inconsistent. It's not because of compatibility since it's available even in HTML 4.01. My only guess is that it's there to provide an alternative validation paradigm, but it sounds like over-engineering.


More From » html

 Answers
13

Not only it provide validation for max length, it also adds a class ng-invalid-maxlength.
so when you put anything beyond the limit ng-invalid-maxlength class will placed there
and in that class you can write your own css.



So after key press if validation fails, the css will be invoked simultaneously and reflects on your UI.


[#68818] Monday, November 10, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raveno

Total Points: 453
Total Questions: 92
Total Answers: 92

Location: France
Member since Thu, Oct 27, 2022
2 Years ago
raveno questions
;