我正在尝试在 ng-repeat 中使用 select2 但它不起作用。这是我的代码。
HTML
<div ng-controller="mycontroller" ng-app="app">
<div ng-repeat="x in y">
<input type="hidden" id="change{$$index$}"/>
</div>
</div>
AngularJS
var myapp = angular.module('app', ['ui.bootstrap']);
myapp.controller('mycontroller',function($scope){
$scope.y=[1,2]
var change1 = $('#change1');
$(change1).select2({
data:[{'id':1,'text':'Manager'},{'id':2,'text':'Employee'}],
multiple: false,
width: "100%",
placeholder:"None Selected",
closeOnSelect:true
});
})
请帮忙。谢谢