Skip to content

Invalidate state not working when bind to ngModel #1397

Discussion options

You must be logged in to vote

Hi,

In the examples, we're appending ng-invalid and ng-dirty classes manually to show how an invalid state looks like. As you see, we're using class attribute of HTML, not ngClass. Because the class overrides the ngClass value. That's why your classes don't appear in DOM, because you're appending classes with ngClass. ng-invalid and ng-dirty classes belong to Angular and usually it's not used like this, they are appended automatically by angular using ngClass. That's why it doesn't work. If you create a formControl and validation logic you'll see that the classes will append automatically.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cetincakiroglu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants