防止在 Angular UI 树中拖动
Prevent dragging in Angular UI Tree
是否有可能阻止用户拖动 Angular UI 树节点?有一个选项 "nodrop" 并且有效,但我也想防止拖动。
<div ui-tree id="tree-root" data-drop-enabled="false">
<ol ui-tree-nodes ng-model="org.data">
<li ng-repeat="node in org.data" ui-tree-node ng-include="'mnuRenderer.html'"></li>
</ol>
</div>
事实证明它可以被禁用,但只能从其 .js 文件内部禁用
angular-ui-tree.js
...
angular.module('ui.tree')
.controller('TreeController', ['$scope', '$element',
function ($scope, $element) {
this.scope = $scope;
$scope.$element = $element;
$scope.$nodesScope = null; // root nodes
$scope.$type = 'uiTree';
$scope.$emptyElm = null;
$scope.$callbacks = null;
$scope.dragEnabled = false;
$scope.emptyPlaceholderEnabled = true;
$scope.maxDepth = 0;
$scope.dragDelay = 0;
$scope.cloneEnabled = false;
$scope.nodropEnabled = false;
...
选项如下:$scope.dragEnabled
更新
我发现该选项与 data-nodrop
- data-nodrag
一起有一个开关,但它不起作用。
您可以使用默认为 true 的 data-drag-enabled
指令。有关更多详细信息,请查看文档:
https://github.com/angular-ui-tree/angular-ui-tree#data-drag-enabled
<div ui-tree id="tree-root" data-drop-enabled="false" data-drag-enabled="false" >
<ol ui-tree-nodes ng-model="org.data">
<li ng-repeat="node in org.data" ui-tree-node ng-include="'mnuRenderer.html'"></li>
</ol>
</div>
是否有可能阻止用户拖动 Angular UI 树节点?有一个选项 "nodrop" 并且有效,但我也想防止拖动。
<div ui-tree id="tree-root" data-drop-enabled="false">
<ol ui-tree-nodes ng-model="org.data">
<li ng-repeat="node in org.data" ui-tree-node ng-include="'mnuRenderer.html'"></li>
</ol>
</div>
事实证明它可以被禁用,但只能从其 .js 文件内部禁用
angular-ui-tree.js
...
angular.module('ui.tree')
.controller('TreeController', ['$scope', '$element',
function ($scope, $element) {
this.scope = $scope;
$scope.$element = $element;
$scope.$nodesScope = null; // root nodes
$scope.$type = 'uiTree';
$scope.$emptyElm = null;
$scope.$callbacks = null;
$scope.dragEnabled = false;
$scope.emptyPlaceholderEnabled = true;
$scope.maxDepth = 0;
$scope.dragDelay = 0;
$scope.cloneEnabled = false;
$scope.nodropEnabled = false;
...
选项如下:$scope.dragEnabled
更新
我发现该选项与 data-nodrop
- data-nodrag
一起有一个开关,但它不起作用。
您可以使用默认为 true 的 data-drag-enabled
指令。有关更多详细信息,请查看文档:
https://github.com/angular-ui-tree/angular-ui-tree#data-drag-enabled
<div ui-tree id="tree-root" data-drop-enabled="false" data-drag-enabled="false" >
<ol ui-tree-nodes ng-model="org.data">
<li ng-repeat="node in org.data" ui-tree-node ng-include="'mnuRenderer.html'"></li>
</ol>
</div>