在ng-options/ng-model中設置默認選項時遇到問題。使用ng選項的ng-ng模型
我的問題是,雖然下拉列表中填充了正確的選項,但默認選項爲空。這讓我相信我在做ng模型的時候出了點問題。任何幫助?
我有我使用的表NG-重複遍歷的數組:
$scope.dumpsters = [
{id:"1", sub_customer: 'a'},
{id:"2", sub_customer: 'b'},
{id:"3", sub_customer: 'c'}
]
爲了簡單起見,我有sub_customers的陣列是獨立的:
$scope.subCustomers = [{description:'a'}, {description:'b'}, {description:'c'}];
所以現在在我的表格中,每一行都有一列包含此:
<select ng-model="d.sub_customer" ng-options="v.description for v in subCustomers" ng-change="updateCustomer(d.sub_customer, d.id)"></select>
subCustomer記錄中的獨特屬性是什麼?是描述嗎?你如何將消費者與垃圾箱相匹配? – PSL
你是什麼意思? – austin809
好吧,每個dumspter在$ scope.dumpsters中都有一個sub_customer。該sub_customer與$ scope.subCustomers中的描述匹配。你是這個意思嗎? – austin809