我有一个稍微复杂的对象结构:
$scope.items =
[
{
name: 'something',
complexObject:
{
number: 1,
id: 12345
}
},
…more of those
]
$scope.selectedItem = $scope.items[0];
现在我想创建一个这样的下拉框:
<select
ng-options="item as item.complexObject.number for item in items track by items.complexObject.id"
ng-model="selectedItem">
当我selectedItem
用另一个项目更新时,相应的数字会显示在下拉框中。但是当我从框中选择一个项目时, selectedItem 不会更新。但我注意到的是,我选择的所有选项都会在 DOM 中获得“选定”标签。
有什么建议吗?