3 views

Classes and Associated NgModel Properties in Angular

  • ng-untouched
  • ng-touched
  • ng-pristine
  • ng-dirty
  • ng-valid
  • ng-invalid

NgModel Properties

  • untouched
  • touched
  • pristine
  • dirty
  • valid
  • invalid
<form #form="ngForm" ngNativeValidate>
    <div class="form-group">
        <label for="name">Name</label>
        <input id="name" name="name" class="form-control" required  #propertyTest="ngModel" />
       </div>
    <button class="btn btn-primary">Send</button>
</form>
<h4>dirty: {{propertyTest .dirty}}</h4>
<h4>pristine: {{propertyTest .pristine}}</h4>
<h4>touched: {{propertyTest .touched}}</h4>
<h4>untouched: {{propertyTest .untouched}}</h4>
<h4>valid: {{propertyTest .valid}}</h4>
<h4>invalid: {{propertyTest .invalid}}</h4>

Leave a Reply