@guidosl wrote:
I need to execute a children component code only one-time, from the father in
ngAfterViewInit()
methodWhen I use
@ViewChild
this returnundefined
for the time it takes to load certain http requests.
I want to avoid usingsetTimeout
since I do not know how long it can take http requestsusing
@ViewChildren
I get to know when the child component is not null
but my code is executed multiple timesngAfterViewInit(){
this.childPage.changes.subscribe((comps: QueryList) =>
{
// Now you can access to the child component
if(this.childPage.last != null){
// I execute my code here
this.childPage.last.someMethod();
}
});
}same problem using a setter for
@ViewChild()
@ViewChild(ChildPage) set childPage(childPage: ChildPage) {
if(childPage!= null){
// I execute my code here
this.childPage.someMethod();
}
);Any idea how to achieve this?
Posts: 1
Participants: 1