How to reset form in ng2, I allready use method form.reset(), but after reset I have still checked checkboxes on form. Question is, how can I uncheck checkboxes in form?
<form #f="ngForm" [formGroup]="taskCreate" (submit)="onSubmit(taskCreate)">
<fieldset class="form-group">
<label for="goal">Cel: </label>
<select name="goal" class="form-control" formControlName="goal" ngControl="goal">
<option *ngFor="let goal of goals" [value]="goal.key" [selected]="key === 'first'">{{ goal.value }}</option>
</select>
<div class="alert alert-danger" *ngIf="this.formValid.goalErr">You must select a goal.</div>
</fieldset>
<fieldset class="form-group">
<label for="p">Priorytet:</label>
<div name="p">
<input class="priority" style="display: table-cell; vertical-align: text-bottom;" type="radio" value="PML" name="priority" formControlName="priority">
<img style="margin-right: 5px;" [src]="this.minustwo" alt="minustwo" />
<input class="priority" style="display: table-cell; vertical-align: text-bottom;" type="radio" value="PL" name="priority" formControlName="priority">
<img style="margin-right: 5px;" [src]="this.minusone" alt="minusone" />
<input class="priority" style="display: table-cell; vertical-align: text-bottom;" type="radio" value="PN" name="priority" formControlName="priority">
<img style="margin-right: 5px;" [src]="this.zero" alt="zero" />
<input class="priority" style="display: table-cell; vertical-align: text-bottom;" type="radio" value="PH" name="priority" formControlName="priority">
<img style="margin-right: 5px;" [src]="this.plusone" alt="plusone" />
<input class="priority" style="display: table-cell; vertical-align: text-bottom;" type="radio" value="PMH" name="priority" formControlName="priority">
<img style="margin-right: 5px;" [src]="this.plustwo" alt="plustwo" />
</div>
<div class="alert alert-danger" *ngIf="this.formValid.priorityErr">You must select a priority.</div>
</fieldset>
<fieldset class="form-group">
<label for="note">Uwagi do zadania:</label>
<textarea maxlength="2000" class="form-control" name="note" rows="8" cols="40" formControlName="note"></textarea>
<div class="alert alert-danger" *ngIf="this.formValid.noteErr">You must draw a note.</div>
</fieldset>
[...]
TS:
constructor(private appService: AppService, public cartBox: CartBox, public attachments: AttachmentList, private elementRef: ElementRef, private renderer: Renderer) {
super();
this.taskCreate = new FormGroup({
goal: new FormControl("", Validators.required),
prodCodeList: new FormControl("", Validators.required),
note: new FormControl("", Validators.required),
priority: new FormControl("", Validators.required),
attachmentList: new FormControl("")
});
Regards! Bosper