Why does Angular provide ng-maxlength when there is a standard maxlength?

后端 未结 2 551
终归单人心
终归单人心 2021-01-17 10:02

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 all

2条回答
  •  醉梦人生
    2021-01-17 10:17

    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.

提交回复
热议问题