Friday, July 28, 2017

making sure a parent's initialization lifecycle hook is called from a child component in Angular 2

Use an ngOnInit in this way to call a parent's ngOnInit from a child component which will otherwise not go off if the child component has an ngOnInit.

ngOnInit():void {
   super.ngOnInit();
   childishStuff();
}

 
 

Removing the child's ngOnInit would also be another way to get the parent's ngOnInit to fire off, but then you couldn't do childishStuff();

No comments:

Post a Comment