0
我的JSON中包含帳戶,聯繫人和票據信息。它將使用ng-repeat輸出Account
和Contact
作爲下拉菜單,爲用戶提供選項。這是完美的,直到Account
或Contact
只有一個值。帶JSON的Ng選項的問題
HTML
<select class="form-control input-sm"
id="accountSelect" ng-model="option.account"
ng-options="account.id as account.name for account in accounts | orderBy: 'name'">
</select>
的JavaScript
$scope.accounts = info.Account.Account;
JSON的實施例(簡化的)
{
"Account":{
"Account":{
"id":1234567,
"name":"Account Name",
"phone":"123-456-7890"
},
"count":1
},
"Contacts":{
"Contacts":[
{
"id":1234,
"name":"Smith, John",
"accountID":1234567
},
{
"id":56789,
"name":"Smith, Jane",
"accountID":1234567
}
],
"count":2
}
}
對我來說,select
選項都是由undefined
值填充。如果有多個Account
,這工作正常。這是爲什麼?
試試這個排序依據:「account.name」」 –
這並沒有不幸解決此問題,所有的選項都仍然'undefined' – CaptainQuint