如何动态地禁用角的UI用户界面可排序指令 [英] How to dynamically disable ui-sortable directive in angular-ui
本文介绍了如何动态地禁用角的UI用户界面可排序指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我采用了棱角分明的UI使用界面可排序指令排序。是否可以动态启用/禁用基于范围的国家排序功能?所以,我需要有一个按钮,它改变了作用域属性的状态,并根据这个属性排序或者应该工作或没有。
I am using angular-ui for sortable using ui-sortable directive. Is it possible to dynamically enable/disable sortable functionality based on the scope state? So I need to have a button which changes the state of the scope property and depending on this property sortable either should work or not.
推荐答案
角指令支持看,当排序选项更改:
The angular directive supports watching when the sortable options change:
scope.$watch(attrs.uiSortable, function(newVal, oldVal){
因此,所有你需要做的就是看jQueryUI的排序文档,并更新插件正确的属性。
So all you had to do was look at the jqueryui sortable documentation, and update the correct property on the plugin.
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
};
});
这篇关于如何动态地禁用角的UI用户界面可排序指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文