angular - 如何根据条件禁用 Mat-tree 组件?
问题描述
我正在使用Angular Material 6。我无法禁用我的 mat-tree 组件:
<mat-tree>
<!-- // -->
</mat-tree>
解决方案
<any-component *ngIf='your_condition' ... > </any-component>
会工作。例如,
<any-component *ngIf='isShown == true' ... > </any-component>
编辑:我需要在 UI 上显示它。我需要把整棵树变灰
你可以使用@disabled
属性
<mat-tree>
<mat-tree-node [disabled]='isDisabled'> parent node </mat-tree-node>
<mat-tree-node [disabled]='isDisabled'> -- child node1 </mat-tree-node>
<mat-tree-node [disabled]='isDisabled'> -- child node2 </mat-tree-node>
</mat-tree>
推荐阅读
- arrays - 从scala中的整数数组缓冲区中删除所有负元素
- python - (Flask API),让firebase上传的图片有唯一的名字
- javascript - 如何打乱用户添加的数组中的项目并显示结果?
- javascript - 如何在 JavaScript 中对 promise 的“then”结果进行单元测试?
- javascript - 如何使用 JavaScript 将表单数据发送到服务器
- random - 栅格堆栈上的随机点和提取值 500 次存储为列表
- java - Vertx hazelcast集群在重新加载更新的fat-jar时不稳定
- jquery - 在 jquery 上添加值时,我得到无穷大的数字
- azure-ad-b2c - URL 重定向不起作用 Android Azure B2C
- javascript - 图像滑块不滑动图像