[英]Multiple ng-options set default option select not working
我在選擇Angular時選擇默認值時遇到問題。 如果我選擇的選項只有一個值,就可以正常工作
<select id="customerId"
ng-model="customer"
ng-options="customer.id for customer in customersSelect">
</select>
在我的角度js中:
$scope.customer = customer;
但是,如果我嘗試對ng-options
使用多個元素,並且設置了默認選項,則無法正常工作
<select id="customerId"
ng-model="customer"
ng-options="customer.id as customer.name for customer in customersSelect">
</select>
有任何想法嗎?
您可以使用一個option
標簽,如下所示:
<select
id="customerId"
ng-model="customer"
ng-options="customer.id as customer.name for customer in customersSelect">
<option value="">PLease select one</option>
</select>
而已。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.