Conditional reset method "if disable ignore not disable reset" angular



    <input type="text" [(ngModel)]="name" [disabled]="editData"
  <input type="text" [(ngModel)]="address" 

<button (click)=add() >add</button>
<button (click)=edit()>edit</button>
<button (click)=reset()>reset</button>

Note:- On add() both fields should be reset but on edit only address field should be reset by without disturbing previous value in it (ignore disabled field)

ts file

reset(){""; this.address="";


by doing this all fields are getting reset


reset(): void{ 
   if(!this.editData) { = "";
   this.address = this.formvalue.address;

Answered By – rkamlekar

Answer Checked By – David Marino (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.