我想在angularJs中选择一个下拉值并将其保存在服务中,这样我就可以在另一个视图上使用它来显示用户所选的值和完整的下拉列表。但是,当我尝试在controller中记录选定的值。我正在获取undefined的值。请帮助我如何继续。Angular Js dropdown所选值控制器内未定义
<td>
<select name="systems" class="pulldown1" id="systems" ng-model="system.selectedOption" ng-controller="EurexController" required ng-options="option.name for option in system.availableOptions track by option.id" ng-init="system.selectedOption=system.availableOptions[0]" ng-change="changed()"> </select>
</td>
控制器代码:
$scope.system = {
availableOptions: [{
id: 'Domestic 1',
name: 'Domestic 1'
}, {
id: 'Domestic 2',
name: 'Domestic 2'
}, {
id: 'Global',
name: 'Global'
}, {
id: 'Far East',
name: 'Far East'
}],
// selectedOption: {id: 'Domestic 1', name: 'Domestic 1'} //This sets the default value of the select in the ui
};
我使用AngularJS网站。但是提到selectedoption也尝试仍然不可能做到这一点。
console.log($scope.system.selectedOption);
console.log(systems);
这是一个有效的问题,我得到了我的答案。有人可能会说为什么这是低调的? – Praveen