Friday, September 1, 2017

truculent

What if you want to query what is inside of a nested Angular 4 component from a wrapping component in lieu of waiting for the nested component to communicate up to the wrapping component with an EventEmitter? The way to do something like that is to make a ViewChild variable off of the nested component in the wrapping component (put a local reference at the selector tag) and then call a method off of the variable which will have to be defined in the nested component's TypeScript guts. This kinda makes me cranky and is something to probably avoid honestly. In my immediate circumstance wherein it applies to me, I need to do something upon the click of a button in the wrapping component and the nested component's checkboxes will bias the act.

@ViewChild('nestedComponent') nestedAccess: MyComponent;

 
 

...could be my ViewChild variable assuming a local reference of:

#nestedComponent

No comments:

Post a Comment