I'm trying to get a value from dropdown list. but the value doesn't parse from .html to .ts. any help with that, please.
.html file
<mat-card>
<form (submit)="onAddName(nameForm)" #nameForm="ngForm">
<mat-form-field appearance="fill">
<mat-label>select one</mat-label>
<mat-select name="name" id="name">
<mat-option value="NAME_01">NAME 01</mat-option>
<mat-option value="NAME_02">NAME 02</mat-option>
<mat-option value="NAME_03">NAME 03</mat-option>
</mat-select>
</mat-form-field>
</form>
</mat-card>
.ts file
onAddName(form: NgForm) {
if (form.invalid) {
return;
}
this.nameService.addname(
form.value.name,
);
form.resetForm();
}
in .ts file, I've used form.value.<name-from-html>
to get other form values and they worked. only dropdown list is not working. any idea how to slove this.