Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49248

Detect children finish loaded using @ViewChild and *ngIf

$
0
0

@guidosl wrote:

I need to execute a children component code only one-time, from the father in ngAfterViewInit() method

When I use @ViewChild this return undefined for the time it takes to load certain http requests.
I want to avoid using setTimeout since I do not know how long it can take http requests

using @ViewChildren I get to know when the child component is not null
but my code is executed multiple times

ngAfterViewInit(){
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

Read full topic


Viewing all articles
Browse latest Browse all 49248

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>