Free tools Windows power users keep installed
One-click scans. No signup required.
Angular error NG0951 means a required singular child query found no matching result. Check whether the query looks in the right template region, whether its locator matches the intended child, and whether conditional rendering has removed that child. If the child is allowed to be absent, use an optional query and handle its undefined value; keep a required query only when the child must exist.
What NG0951 means
A singular viewChild.required(...) or contentChild.required(...) query asserts that a matching child exists. When Angular evaluates the query and finds no match, it reports NG0951. Unlike an optional singular query, a required query’s signal type does not include undefined.
As an Amazon Associate I earn from qualifying purchases.
Angular notes that a query can have no result when its target is hidden by control flow, such as @if. The exact cause in a particular application depends on its query declaration and template. See Angular’s component queries guide.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchCheck which template region the query searches
Choose the query according to where the target belongs. A query does not look through another component’s template boundary.
#1 Best Overall
viewChildsearches the querying component’s own template.contentChildsearches content supplied to the component, such as projected content.
For a view query, confirm the target is in that component’s template. For a content query, confirm the caller actually supplies the target as content. Angular documents decorator-based ViewChild and ContentChild separately; their syntax and timing options differ from the signal-based initializer APIs.
Verify the locator and whether the target exists
- Find the required query. Identify whether the declaration uses
viewChild.required(...)orcontentChild.required(...). - Check its locator. If it uses a string, make sure it matches the intended template reference. If it uses a token, confirm the target provides the component, directive, or provider represented by that token.
- Follow the relevant template. Check the querying component’s own template for a view query, or the caller’s projected content for a content query.
- Inspect control flow. Look for
@if,@for, or other conditions that can prevent the target from being rendered when Angular reads the query. - Decide whether absence is valid. If the child is optional, change to the optional query form and handle its possibly
undefinedresult. If it is mandatory, correct the locator or template so a matching child exists.
Choose optional or required deliberately
| Query choice | Use it when | Behavior |
|---|---|---|
| Optional singular query | The child may not be present. | The result can be undefined; consuming code must account for that. |
| Required singular query | The child is an invariant and must exist. | Angular reports an error if no matching result is available. |
Do not make a query required merely to avoid checking for undefined. The required form communicates a real template contract: the target must be present whenever Angular evaluates the query.
Rank #2
Do not confuse singular and plural queries
NG0951 concerns a missing result from a required singular child query. viewChildren and contentChildren return collections rather than a single required child. There is also a traversal difference: contentChild searches descendants by default, while contentChildren defaults to direct children unless configured to traverse descendants. Angular’s query guide describes these query behaviors.
Check your Angular version before changing syntax
The signal-based viewChild and contentChild initializer APIs are documented as stable since Angular v19.0. That does not establish which version a given project uses. Check the installed version and follow the API style already used in the codebase before applying a signal-based fix. The API references are viewChild and contentChild.
Rank #3
If the project uses decorator-based @ViewChild or @ContentChild, do not mix in signal-query syntax without first confirming version compatibility and the intended behavior. Consult the corresponding ViewChild and ContentChild references.
Quick Recap
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




