Open rezonant opened 8 years ago
Yeah Angular 1 doesn't wait for child template urls to fully load because it might slow the app way down. I'm wondering if there is an easy way we could at least have the hook wait. Honestly I'm not sure how high of a priority this is to me... I highly recommend keeping your templates inline. But I'll do some thinking on this.
The child's ngAfterViewInit is not called until it's templateUrl is loaded though right? Its just the parent that is running?
Just double checked, the ngAfterViewInit() for the child component itself correctly fires after the template is loaded. Just a parent's ngAfterViewInit() is too early for its children to load their templates.
It appears that if you use templateUrl in a child component, ngAfterViewInit() on the parent component will fire before the child's template is loaded, and thus the componentInstance field will be null for that child.
In my app, simply changing out templateUrl on the component whose componentInstance is null with a template string causes componentInstance to be available. Hopefully I've identified it right since I'm not sure the best way to make a demonstration given the dependencies.