Skip to main content
InterviewHubPRO
Section Overview
Q264

Question 264 of 283

Part 10: Reactive Forms, Standalone Components, Signals & NgRx (256 - 283)

93%
Angular Master (283 Qs)•Part 10: Reactive Forms, Standalone Components, Signals & NgRx (256 - 283)

What are the state CSS classes provided by ngModel?

junior LevelMost AskedCode ExampleSignalsComponentsState Management

The ngModel directive updates the form control with special Angular CSS classes to reflect it's state. Let's find the list of classes in a tabular format,

Form control stateIf trueIf false
Visitedng-touchedng-untouched
Value has changedng-dirtyng-pristine
Value is validng-validng-invalid

Practical Code Example

text
// ngModel State CSS Classes:
// ng-untouched / ng-touched (visited)
// ng-pristine / ng-dirty (value changed)
// ng-valid / ng-invalid (passes validation rules)
// ng-pending (waiting for async validator)