Swaroop Babaleshwar
Swaroop Babaleshwar

Reputation: 211

which component template is loaded first among parent and child component

I have 2 components Parent and Child component

inside parent component template I am using the selector of the Child component.

which component template is loaded first after running the application on a local server

and which component constructor() and ngOnInit() will get executed first ?

when i debug it in my case it executing in the following way

1) constructor() of parent

2)constructor() of child

3)ngOnInit() of parent

4) ngOnInit() of child

Upvotes: 0

Views: 1165

Answers (2)

Jeena
Jeena

Reputation: 1

Yes, Always the parent component is loaded first as child component is a part of parent component it cannot be loaded before parent component

Upvotes: 0

Prakash Dale
Prakash Dale

Reputation: 536

Yes. The sequence you mentioned is correct.

Upvotes: 0

Related Questions