【发布时间】:2017-03-17 16:55:51
【问题描述】:
在我的情况下,有什么方法可以在不使用控制器的情况下为 select 设置默认值?
我尝试了很多方法。这是最后一个...
<select [(ngModel)]="model.carColour" [ngModelOptions]="{standalone: true}" class="form-control input-sm" ng-init="model.carColour='select'">
<option value="select">Select color</option>
<option></option>
<option *ngFor="let item of carscolours" [value]="item.value"> {{item.text}}</option>
</select>
我需要将“选择颜色”设置为默认值,下拉列表中将是空字符串和库中的项目。
【问题讨论】:
-
问题仍然存在
标签: angular select default ng-init ngmodel