好吧,我有这个格式的对象数组
$scope.itemArray = [
{id: 1, name: 'first'},
{id: 2, name: 'second'},
{id: 3, name: 'third'},
{id: 4, name: 'fourth'},
{id: 5, name: 'fifth'},
];
$scope.selectedItem = $scope.itemArray[0];//this works fine
$scope.selectedItem = $scope.itemArray[0].id;//this doesn't works
这是html部分:
<ui-select ng-model="selectedItem">
<ui-select-match>
<span ng-bind="$select.selected.name"></span>
</ui-select-match>
<ui-select-choices repeat="item in itemArray | filter: $select.search">
<span ng-bind="item.name"></span>
</ui-select-choices>
</ui-select>
我要做的是使用
id
但是我不能这么做。我确信我在某个地方是错的,而且对这个插件来说也是非常新的。请帮帮我。