Skip to content

Comments

docs: use viewChild signal queries and modern patterns in code examples#32837

Open
yogeshwaran-c wants to merge 1 commit intoangular:mainfrom
yogeshwaran-c:docs/use-viewchild-signal-queries
Open

docs: use viewChild signal queries and modern patterns in code examples#32837
yogeshwaran-c wants to merge 1 commit intoangular:mainfrom
yogeshwaran-c:docs/use-viewchild-signal-queries

Conversation

@yogeshwaran-c
Copy link

What kind of change does this PR introduce?

Documentation update.

What is the current behavior?

Several documentation files use the decorator-based @ViewChild pattern in
code examples, along with @NgModule providers and constructor injection.
These patterns are outdated since Angular v17+ introduced signal-based queries
and standalone components became the default.

Relates to #32709

What is the new behavior?

  • Replace @ViewChild with viewChild.required() signal queries
  • Replace @ViewChildren prose references with viewChildren
  • Replace @NgModule provider blocks with bootstrapApplication
  • Replace constructor injection with inject()
  • Replace AfterViewInit lifecycle with afterNextRender

Files changed

File Changes
src/cdk/a11y/a11y.md @ViewChildren -> viewChildren in prose
src/google-maps/google-map/README.md Remove ViewChild decorator reference from prose
src/google-maps/map-info-window/README.md @ViewChild -> viewChild.required() in example
src/material/core/ripple/ripple.md @ViewChild -> viewChild.required(), @NgModule -> bootstrapApplication, constructor -> inject()
src/material/datepicker/datepicker.md @ViewChild -> viewChild.required() with generic type
src/material/menu/menu.md @ViewChild -> viewChild.required() in example
src/material/sidenav/sidenav.md @ViewChild -> viewChild.required(), AfterViewInit -> afterNextRender

Additional context

All signal query calls use viewChild.required() since the queried elements are
expected to always exist in the template. Signal queries return a Signal<T>, so
the call-site invocation syntax changes from this.foo.method() to
this.foo().method().

@pullapprove pullapprove bot requested review from andrewseguin and tjshiu February 23, 2026 21:06
@angular-robot angular-robot bot added the area: docs Related to the documentation label Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs Related to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant