我有以下问题: 让我们假设我有Component A
有两个subcomponents Ar
和Ad
。 Subcomponent Ar
是递归创建树,subcomponent Ad
是显示有关递归树中选定节点的详细信息的组件(subcomponent Ar
)。如何使用@Output
从Ar
中的子(子)组件向Component Ad
发送选定节点?应该是@Output
还是别的?Angular2递归组件输出
app.component.html:
<tree [input]="fooTree" [output]="updateDetails($event)"></tree>
<tree-details [input]="input"></tree-details>
tree.component.html:
<tree [input]="fooTree.children"></tree>
树details.component.html
<div>{{input.name}}</div>
<div>{{input.id}}</div>
在这种情况下,我只会看到根树的详细信息,如何才能从其他节点(递归创建的一个节点)获取信息,何时被选中?
但随着tree.component.html什么?不应该有任何输出? – ulou
是的,它的递归,不记得它.. – mxii
这是我需要的exatcly。非常感谢你 :) – ulou