Angular is automatically adding 'ng-invalid' class on 'required' fields

后端 未结 5 1162
暖寄归人
暖寄归人 2020-12-24 05:41

I am building an angular app for which I have some forms set up. I have some fields that are required to be filled before submission. Therefore I have added \'required\' on

5条回答
  •  旧巷少年郎
    2020-12-24 06:25

    Since the fields are empty they are not valid, so the ng-invalid and ng-invalid-required classes are added properly.

    You can use the class ng-pristine to check out whether the fields have already been used or not.

提交回复
热议问题