【发布时间】:2014-01-10 02:21:15
【问题描述】:
如何使用 Angular 的 ng-repeat 指令显示两个带有正确选项的下拉菜单?
这是JSBin
js:
angular.module('myApp', [])
.controller('MainCtrl', function($scope) {
$scope.templates = {
pages: ['home', 'about'],
posts: ['blog', 'lab']
};
});
HTML:
<div class="container" ng-controller="MainCtrl">
<form action="" class="col-lg-12" >
<select class="form-control" ng-repeat="template in templates.pages>
<option value = "{{ template }}"> {{ template }}</option>
</select>
<select class="form-control" ng-repeat="template in templates.posts>
<option value = "{{ template }}"> {{ template }}</option>
</select>
</form>
</div>
【问题讨论】:
标签: javascript html angularjs angularjs-ng-repeat 2-way-object-databinding