<form #userForm="ngForm">
    <input type="text" ngModel name="firstName" required>
    <input type="text" ngModel name="lastName" required>
    <button (click)="submit(userForm.value)">Save</button>
</form>
  • [ ]
<button (click)="submit(userForm.value)"
  disable="userForm.invalid">
Save</button>
  • [x]
 <button (click)="submit(userForm.value)"
  [disabled]="userForm.invalid">
Save</button>
  • [ ]
 <button (click)="submit(userForm.value)"
  [ngForm.disabled]="userForm.valid">
Save</button>
  • [ ]
 <button (click)="submit(userForm.value)"
  *ngIf="userForm.valid">
Save</button>

By Neha S

Leave a Reply

Your email address will not be published.