如何使用angular的ng-repeat指令显示两个带有正确选项的下拉菜单?
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>