嗨,我正在用angularjs开发Web应用程序。我有一页,在一个网页中,我显示了三棵单独的树。因此,我创建了不同的树组件。我在下面添加了一个树组件。
<tree-root #tree
[nodes]="nodesAdd"
[options]="options">
<ng-template #treeNodeTemplate let-node="node" let-index="index">
<input type="checkbox" (change)="toggle($event.target,node)"
[checked]="node.data.checked">
{{ node.data.name }}"
</ng-template>
</tree-root>
我正在将节点分配给树组件,如下所示。
addnodestoaddoperation(result) {
var resultaray = [];
resultaray = [
{
name: 'Info model', checked: false,
children: [
{ name: result[0], checked: false },
{ name: result[1], checked: false }
]
},
{
name: 'Data Access',
children: [
{ name: result[0], checked: false },
{ name: result[1], checked: false }
]
}
];
this.nodesAdd = [
{
name: 'Event Subscriptions', checked: false,
children: [
{ name: 'Variables', checked: false },
{ name: 'Alarms', checked: false },
{ name: 'Events', checked: false },
{ name: 'Platform Events', checked: false }
],
},
{
name: 'Reingestion', checked: false
},
{
name: 'Command', checked: false
},
{
name: 'Type Registry', checked: false,
children: [
{ name: 'Model Definitions', checked: false },
{ name: 'Type Definitions', checked: false }
]
}
];
this.nodesAdd = resultaray.concat(this.nodesAdd);
this.tree.treeModel.update();
console.log("addnodes:" + JSON.stringify(this.nodesAdd));
}
使用上述代码,我无法显示树组件。只有当我有
时,它才有效
[nodes]="nodes"
和this.nodes = resultaray.concat(this.nodesAdd);
但是我想要下面的东西。有人可以帮我怎么做吗?任何帮助,将不胜感激。谢谢。
[nodes]="nodesAdd" [nodes]="nodesDelete" [nodes]="nodesEdit"