问问题
1078 次
2 回答
0
用 ng-model 说这是你的选择
<select
ng-model="language.selected"
ng-init="language.selected = settings.language[settings.language.selected.id]"
ng-options="l.label for l in settings.language"
ng-change="updateLanguage(language.selected)">
在您的控制器中
$scope.settings = {
enableEventsNotification: true,
enableiBeaconNotification: true,
hours: [
{ id: 0, label: '3h', value: 3 },
{ id: 1, label: '6h', value: 6 },
{ id: 2, label: '9h', value: 9 },
{ id: 3, label: '12h', value: 12 },
{ id: 4, label: '24h', value: 24 }
],
language: [
{ id: 0, label: 'English', value: 'en-us' },
{ id: 1, label: 'Francais', value: 'fr-fr' }
]
};
$scope.hours = [];
$scope.hours.selected = $localstorage.getObject('hours', $scope.settings.hours[1]);
$scope.settings.hours.selected = $localstorage.getObject('hours', $scope.settings.hours[1]);
$scope.hours.selected = $scope.hours.selected;
于 2015-03-30T02:24:17.680 回答
0
我认为您需要根据 select 指令中定义的理解表达式确保selectedContentType
需要成为id
选项对象的字段。
综合表达式定义为
item.id as item.name for item in option.contentTypesPlus
item.id
将是存储在ng-model
option.selectedContentType
于 2013-08-08T05:42:36.643 回答