【发布时间】:2021-01-03 08:01:56
【问题描述】:
我是 Angular 的初学者,我想在材质树的子元素中显示数组的值。
比如我想在子元素中显示fruitList的名称(Apple, Banana...)。数组中的颜色和折扣需要存储为变量,在别处会用到,不能被删除。
我在这里有一个工作示例:stackblitz example
const TREE_DATA: FoodNode[] = [{
fruit: "fruit_1",
fruitList: [
{ name: "Apple", color: "red", discount: false },
{ name: "Banana", color: "yellow", discount: true },
{ name: "Grape", color: "purple", discount: true }
]},{
fruit: "fruit_2",
fruitList: [
{ name: "Lemon", color: "pale yellow", discount: false },
{ name: "Kiwi", color: "green", discount: false },
{ name: "Strawberry", color: "red", discount: true }
]}];
你能告诉我如何在我的 mat-tree 中显示上面的 json 吗?
【问题讨论】:
标签: javascript json angular angular-material