I have created an angular form using materialize-css. Here is the HTML
<form [formGroup]="addFeedForm" (ngSubmit)="addFeed(addFeedForm.value)" class="col s12">
<div class="row">
<div class="input-field col m6 s12">
<select formControlName="departmentId" #feedDepartment>
<option value=0>General</option>
<option [value]="department.id" *ngFor="let department of departmentList">{{department.name}}</option>
</select>
<label>Department</label>
</div>
<div>
<button type="button" class="btn waves-effect waves-light col s3 offset-s5" (click)="resetAddFeedForm()">Reset</button>
<button type="submit" [disabled]="!addFeedForm.valid" class="btn waves-effect waves-light col s3 offset-s1">Add</button>
</div>
</div>
</form>
And this is how I have created the angular form
this.addFeedForm = new FormGroup({
departmentId: new FormControl(0,Validators.compose([Validators.required])),
});
And when I submit I do
addFeed(data: any): void {
console.log(data);
this.addFeedForm.reset({ departmentId: 0 });
}
If I change the department select option to something else and submit and reset the form by setting departmentId to be 0 then "General" should be selected in the select option.
It is not updating on the UI but on the console, it sets departmentId to 0.
on the UI selected option is different but on the console departmentId is 0
Update : This is the stackblitz
