Angular 5 + Material Design: <mat-select> how to set the default value?
<mat-form-field>
<mat-select [formControl]="form.controls['defaultCategory']" [(ngModel)]="resource.categoryName" >
<mat-option *ngFor="let category of categories | async" [value]="category._id" >
{{ category.name }}
</mat-option>
</mat-select>
</mat-form-field>
I've tried a lot. The docs, some error messages on github still don't solve my problem.
I only need to preset the default value ...
The default value is stored in a variable named: resource.categoryName. The parameters are taken from the mongodb collection, and they are stored in categories [].
This image shows a closed mat-selection (the default value is not specified, but it should ...)
.ts , . . ( , ) - , .
+4
1