當我從選擇列表中更改數值,第一個變化顯示始終是空的,第二個變化後我有顯示第一個變化顯示空總是空白
我嘗試使用此代碼:
<select name="app_category_id" ng-model="campaign.app_category" ng-options="app_category.id as app_category.name group by app_category.app_category_pool[0].name for app_category in app_category_list | orderBy:['app_category_pool[0].name', 'name'] track by app_category.id" required>
</select>
我的列表:
:$scope.app_category_list = [{
"id": 31,
"code": "RED",
"name": "Red",
"app_category_pool": [{
"id": 1,
"code": "CATEGORY_1",
"name": "Category 1"
}]
}, {
"id": 32,
"code": "BLUE",
"name": "Blue",
"app_category_pool": [{
"id": 1,
"code": "CATEGORY_1",
"name": "Category 1",
}]
}, {
"id": 33,
"code": "YELLOW",
"name": "Yellow",
"app_category_pool": [{
"id": 2,
"code": "CATEGORY_2",
"name": "Category 2",
}]
}]
第一個變化之後(從列表中的其他項目的選擇)
第二變動後(從列表中的其他項目的選擇):
我謹
類別使用ID和組當我打開我的網頁,我的campaign.app_category擁有一個值,之後我選擇另一個項目,並且顯示空白:
$scope.campaign = {
app_category: {
"id": 31,
"code": "RED",
"name": "Red",
"app_category_pool": [{
"id": 1,
"code": "CATEGORY_1",
"name": "Category 1"
}]
}
}
我用角1.5.8
解決
http://plnkr.co/edit/6XYAQXG6hVh2J2PkfXIG?p=preview
無法重現:http://plnkr.co/edit/5B7PcdZxaaqdZ7R5Nvjc?p=preview – dfsq
事件與角度1.5.8,這是工作正常.. http://plnkr.co/edit/oTlUF94kprSMTjAv68gq?p =預覽 –
http://stackoverflow.com/questions/18194255/how-to-have-a-default-option-in-select-box-angular-js希望這會解決你的問題。 – Aravind