[英]To set the default value in the dropdown in angular 6
只需添加:
selectedCustomer = '01';
在模板中使用[(ngModel)]
:
<div class="main-div">
<h3>List</h3>
<mat-form-field>
<mat-select
placeholder="Select Customer"
[(ngModel)]="selectedCustomer">
<mat-option
*ngFor="let customer of customers"
[value]="customer.id"
(click)="selected($event, customer.id)">
{{customer.name}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
这是供您参考的工作样本StackBlitz 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.