【问题标题】:Get destination node in Angular UI Tree在 Angular UI 树中获取目标节点
【发布时间】:2017-08-16 02:17:52
【问题描述】:

我使用Angular UI Tree 作为文件系统的用户界面。我希望能够将项目放入文件夹而不是文件,因此树中的所有项目都有一个类型属性,其值为“文件”或“文件夹”。

如何检查此属性并根据值允许或禁止放入项目?我尝试在接受回调中添加检查。 sourceNodeScope 为我提供了我在sourceNodeScope.$modelValue.type 中移动的节点的类型,但destNodesScope.$modelValue 似乎在我移动的项目和目的地之间交替。当它是目的地时,它是树中该级别所有节点的数组。

accept: function(sourceNodeScope, destNodesScope, destIndex) {

});

【问题讨论】:

    标签: angularjs angular-ui-tree


    【解决方案1】:

    这可以使用 beforeDrop 方法而不是接受来实现。事件上的 dest 可用于检查目的地,如果允许放置,则应返回 true。

    $scope.treeOptions = {
      beforeDrop: function (e) {
        var destValue = e.dest.nodesScope.node ? e.dest.nodesScope.node.type : undefined
    
        if (destValue === 'file') {
          return false
        }
        return true
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-25
      相关资源
      最近更新 更多