我正在使用ui-select2并尝试点击编辑按钮打开新页面.我看到一些奇怪的问题.我第一次打开新页面时它打开正常,但是当我取消它并再次打开同一页面时,通过单击编辑,它会给我以下错误:
select2.full.min.js:3 The select2('destroy') method was called on an element that is not using Select2
angular.js:13708 TypeError: Cannot read property 'destroy' of undefined
at n.a.fn.select2 (select2.full.min.js:3)
at HTMLSelectElement.<anonymous> (select2.js:175)
at HTMLSelectElement.dispatch (jQuery-2.1.4.min.js:3)
at HTMLSelectElement.r.handle (jQuery-2.1.4.min.js:3)
at Object.trigger (jQuery-2.1.4.min.js:3)
at n.triggerHandler (jQuery-2.1.4.min.js:3)
at Function.pa.fn.on.pa.cleanData (angular.js:1865)
at n.remove (jQuery-2.1.4.min.js:3)
at angular.js:5504
at Object.push (angular.js:5085)
Run Code Online (Sandbox Code Playgroud)
通过阅读这个消息,似乎我将不得不定义destroy方法,但我没有得到如何在我的控制器中定义destroy方法以及如何调用取消按钮(取消方法)调用..以下是select的代码片段:
<select ui-select2 class="form-control input-lg" ng-model="cityId" ng-change="loadLocality()">
<option ng-repeat="city in cities|orderBy:'name'|filter:'ACTIVE':true" value="{{city.id}}">{{city.name}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)