【问题标题】:Use *ngIf to filter tree nodes in clarity recursive tree使用 *ngIf 过滤清晰递归树中的树节点
【发布时间】:2019-07-10 13:27:52
【问题描述】:

我有一个递归清晰度树

<clr-tree>
  <clr-tree-node 
      *clrRecursiveFor="let type of displayedTypes; getChildren: getTypeChildren" 
      [(clrSelected)]="type.selected"    
      [(clrExpanded)]="type.expanded"
    >
      {{type.name}}
    </clr-tree-node>
</clr-tree>

但我想过滤一些树节点。在一个简单的情况下,我会使用 *ngIf 指令。但是我这里已经有另一个指令*clrRecursiveFor。 所以我试着把它包装成ng-container

<clr-tree>
    <ng-container  *clrRecursiveFor="let type of displayedTypes; getChildren: getTypeChildren" > 
      <clr-tree-node *ngIf="isVisible(type)"...>
          ...
        </clr-tree-node>
        </ng-container>
    </clr-tree>

您可以在 app.component.html 中看到一些示例 here

但在这种情况下,即使isVisible 始终返回 true,也不会显示任何内容。如何在此处使用 *ngIf 指令来过滤树节点?

【问题讨论】:

  • Elma,这个问题的解决方案帮不了我。
  • 你能添加stackblitz代码吗?
  • 你能添加正确的依赖,css并让它工作吗?
  • 我认为这是这个库的一个内部错误,他们试图获取上下文,即使它不存在......你可以过滤你的数组并始终显示它的所有元素跨度>

标签: angular vmware-clarity


【解决方案1】:

现在不可能了。最好在组件中过滤数组。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-12
    相关资源
    最近更新 更多