![](/img/trans.png)
[英]How to set the value of an option when using ng-options in controller?
[英]Using ng-options for select when using as notation for controller
我有一个选择,使用 ng-options 来定义当我在 ng-controller 指令中只使用控制器名称时可以正常工作的选项。 问题是,当我向 ng-controller 添加“作为选项”时,它不再起作用(没有选项)。
不起作用:
<div ng-controller="optionsCtrl as options">
<select ng-model="options.oxygenSource" ng-options="item.name for item in options.oxygenSources"></select><br />
</div>
作品:
<div ng-controller="optionsCtrl">
<select ng-model="oxygenSource" ng-options="item.name for item in oxygenSources"></select>
</div>
如果有帮助,这是我的控制器:
.controller('optionsCtrl', ['$scope', 'adminServ', function ($scope, adminServ) {
// User selections
$scope.oxygenSource = null;
$scope.oxygenSources = adminServ.getOxygenSources();
}])
有什么想法吗? 谢谢,杰森
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.