角度指令支持在排序选项更改时观察:
原文链接:https://www.f2er.com/angularjs/140355.htmlscope.$watch(attrs.uiSortable,function(newVal,oldVal){
所以您只需查看jqueryui可排序的文档,并更新插件上的正确属性.
HTML
<ul ui-sortable="sortableOptions" ng-model="items"> <li ng-repeat="item in items">{{ item }}</li> </ul> <button ng-click="sortableOptions.disabled = !sortableOptions.disabled">Is Disabled: {{sortableOptions.disabled}}</button>
JS
app.controller('MainCtrl',function($scope) { $scope.items = ["One","Two","Three"]; $scope.sortableOptions = { disabled: true }; });