Issue
Is it possible to clear/reset a form with a single button? The form contains material datepicker, input, textarea, select and checkboxes.
My actual code:
<form class="example-form" #form="ngForm">
<button mat-raised-button color="primary (click)="clear(form.value)">Clear</button>
<mat-form-field class="example-full-width">
<input matInput placeholder="Name" name="name" ngModel>
</mat-form-field>
<mat-form-field>
<input matInput [matDatepicker]="birthday" [(ngModel)]="geburtsdatum" placeholder="Geburtsdatum" name="geburtsdatum">
<mat-datepicker-toggle matSuffix [for]="birthday"></mat-datepicker-toggle>
<mat-datepicker #birthday></mat-datepicker>
</mat-form-field>
<mat-checkbox [(ngModel)]="unlimited" name="unbegrenzt">unlimited</mat-checkbox>
<mat-form-field>
<mat-select placeholder="Transpondertyp" name="transponderTyp" [(ngModel)]="form.transponderTyp">
<mat-option>None</mat-option>
<mat-option *ngFor="let transponderTyp of transponderTyps" [value]="transponderTyp.value">
{{ transponderTyp.viewValue }}
</mat-option>
</mat-select>
</mat-form-field>
</form>
Thanks in advance :-)
Best regards
Solution
<button (click)="form.reset()" >RESET</button>
use reset() method of TD form
Answered By - Suhag Lapani88
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.