Invalidate state not working when bind to ngModel #1397
-
Hi How to fixed it , Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, In the examples, we're appending |
Beta Was this translation helpful? Give feedback.
Hi,
In the examples, we're appending
ng-invalid
andng-dirty
classes manually to show how an invalid state looks like. As you see, we're usingclass
attribute of HTML, notngClass
. Because theclass
overrides thengClass
value. That's why your classes don't appear in DOM, because you're appending classes with ngClass.ng-invalid
andng-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.