@ViewChildren(Subcomponent) sComp;
将让我获得当前组件的子组件子代,但我想获取作为子组件子代的元素的值。我该怎么办?
答案 0 :(得分:2)
在Subcomponent
中,您可以定义一个方法来返回其子级:
@ViewChildren(ChildA) childAOfSubcomponent;
getChildA() {
return this.childAOfSubcomponent;
}
现在在当前组件中使用此:
this.sComp.getChildA(); // thi will return child of SubComponent