liveBook · Manning

ViewChildren

As explained in Modern Angular

viewChildren is an Angular query function that returns a signal containing references to matching elements or components in a component view.

ViewChildren is Angular’s signal-based query function for obtaining references to multiple HTML elements or components declared in a component view. It modernizes the decorator-based @ViewChildren approach by returning a signal containing an array of matching references. section 7.5.3 section 10.3.4

The signal updates when matching elements are added to or removed from the query result. Computed signals can derive values from the references, while effects can react to changes without manually synchronizing a secondary property. section 10.3.4 section 10.3.4

ViewChildren fits Angular’s broader signal-based query direction:

  • Use viewChildren for multiple elements or components in the view; use viewChild for a single reference. section 7.5.3
  • Use contentChildren instead when the queried elements belong to projected content. section 7.5.3
  • Avoid the older setter-and-secondary-property pattern previously needed to observe QueryList changes. section 10.3.4

How Modern Angular covers it

How deep it goes
Explains signal results, computed dependencies, effects, and automatic query updates, but does not provide a complete implementation listing.
Examples
Uses multiple HTML elements or components, including elements dynamically added to or removed from a QueryList.
What it assumes
Contrasts ViewChildren with decorator-based @ViewChildren and assumes familiarity with Angular component templates and signals.
What you can do after
Evaluate reactive view-query behavior and choose signal-based queries for observing multiple view references.
How it connects
Connects ViewChildren with signals, QueryList, computed signals, effects, viewChild, and contentChildren.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern Angular. The section links point to the parts of the book it draws on.