2015-10-20 195 views
1

我有一個問題,選擇一個默認值與角選擇。 如果我選擇的選項只有一個值it's OK和工作正常多ng選項設置默認選項選擇不工作

<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> 

任何想法?

+0

這有幫助嗎? http://stackoverflow.com/questions/20845210/setting-selected-values-for-ng-options-bound-select-elements – Ric

回答

0

您可以使用下面一個option tag.like:

<select 
     id="customerId" 
     ng-model="customer" 
     ng-options="customer.id as customer.name for customer in customersSelect"> 
     <option value="">PLease select one</option> 
</select>       

完蛋了。

+0

是不是我要找的,但謝謝 – paul