本文介绍了任何人都可以解释ngoptions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



任何人都可以解释这段代码:

鉴于$ scope上的这一系列项目:



$ scope.items = [{

id:1,

label:'aLabel',

subItem:{name:' aSubItem'}

},{

id:2,

label:'bLabel',

subItem: {name:'bSubItem'}

}];



< select ng-options =item as item.label for item in项目按项目跟踪.idng-model =selected>< / select>



在ng-options中我们指定了

item as item.label for item in item by item.id任何人都可以解释这句话

Hi,
can anyone explain this code:
Given this array of items on the $scope:

$scope.items = [{
id: 1,
label: 'aLabel',
subItem: { name: 'aSubItem' }
}, {
id: 2,
label: 'bLabel',
subItem: { name: 'bSubItem' }
}];

<select ng-options="item as item.label for item in items track by item.id" ng-model="selected"></select>

In ng-options we have specified
"item as item.label for item in items track by item.id" can anyone explain this statement

推荐答案



Select the item.label from the items array where the selected value matches the item.id


这篇关于任何人都可以解释ngoptions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 22:43
查看更多