首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >angular-tree-component |获取路径

angular-tree-component |获取路径
EN

Stack Overflow用户
提问于 2018-01-05 21:25:05
回答 1查看 770关注 0票数 0

有人知道当我点击一个节点时,如何获得完整的路径吗?我在API中看到了路径选项,但我不知道如何在单击事件中使用它。

代码语言:javascript
复制
options: ITreeOptions = {
 actionMapping: {
  mouse: {
    dblClick: (tree, node, $event) => {

    }
  }
 }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-05 23:23:36

根据您需要的格式,您可以自己构建谱系/路径

代码语言:javascript
复制
options: ITreeOptions = {
    actionMapping: {
        mouse: {
            dblClick: (tree, node, $event) => {
                const lineage = [];
                // add clicked node as first item
                lineage.push(node.data);

                // grab parent of clicked node
                let parent = node.parent;

                // loop through parents until the root of the tree is reached
                while(parent !== null){
                    lineage.push(parent.data);
                    parent = parent.parent;
                }
            }
        }
    }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48114561

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档