CodeZettaInterview Hub

Angular · Components · Fresh / Intern · Comparison

How do ViewChild and ContentChild differ?

Short Interview Answer

ViewChild queries the component's own template; ContentChild queries projected content.

Detailed Explanation

Timing matters: queries are available after ngAfterViewInit / ngAfterContentInit. Prefer signal queries (viewChild, contentChild) in modern Angular. Avoid querying too early in the constructor.

Did you know this answer?