adisplayname
adisplayname

Reputation: 127

In Angular, with ViewChild/ ViewChildren, how do I get the child of a child?

@ViewChildren(Subcomponent) sComp;

Will get me the Subcomponent children of my current component, but I want to get the values of elements that are children of Subcomponent. How do I do that?

Upvotes: 0

Views: 390

Answers (1)

nircraft
nircraft

Reputation: 8478

In Subcomponent you can have a method defined to return it's child:

@ViewChildren(ChildA) childAOfSubcomponent;

getChildA() {
  return this.childAOfSubcomponent;
}

Now in current component use this:

this.sComp.getChildA();  // thi will return child of SubComponent

Upvotes: 3

Related Questions