2015-10-20 174 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