我正在拉入一组对象作为 $scope.templates
。我希望能够将 $scope.item.steps
(我选择的模型名称)设置为 template.steps
的值,用于我的 ng- 中的选定选项选项数组。有没有一种无需添加额外的 Controller 逻辑即可执行此操作的简单方法?
<select class="form-control" ng-options="template.name for template in templates" ng-model="item.steps">
最佳答案
当然,使用 select as label for value in array
语法:
<select class="form-control" ng-options="template.steps as template.name for template in templates" ng-model="item.steps">
关于javascript - 如何将 ng-option 模型设置为对象的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30959133/