Reputation: 6852
I have some function like this:
cancel(): void {
this.form.reset();
this.router.navigate([], { queryParams: { activeOnly: false } });
}
And in html like this:
<select class="form-control-sm" id="select-process-type" formControlName="processType">
<option [selected]="!form.get('processType').value" disabled>
{{'type' | translate}}
</option>
<option [value]="'1'" [innerHTML]="'1' | translate">
</option>
<option [value]="'2'" [innerHTML]="'2' | translate">
</option>
<option [value]="'3'" [innerHTML]="'3' | translate">
</option>
</select>
The problem I have is that when I call
this.form.reset();
It clear all value with form, not even first is diplayed, because first option i use like placeholder
Here what it should look
And this is what it does
Upvotes: 2
Views: 136
Reputation: 22213
Set [value]="null"
in the default option.
Try like this:
<option [selected]="!form.get('processType').value" [value]="null" disabled>
{{'type' | translate}}
</option>
Upvotes: 1