Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

contentChildren

Initializes a content children query.

See more...

      
      contentChildren(locator: string | ProviderToken<LocatorT>, opts?: { descendants?: boolean; read?: undefined; }): Signal<ReadonlyArray<LocatorT>>
    
Parameters
locator string | ProviderToken<LocatorT>
opts object

Optional. Default is undefined.

Returns

Signal<ReadonlyArray<LocatorT>>


      
      contentChildren(locator: string | ProviderToken<LocatorT>, opts: { descendants?: boolean; read: ProviderToken<ReadT>; }): Signal<ReadonlyArray<ReadT>>
    
Parameters
locator string | ProviderToken<LocatorT>
opts object
Returns

Signal<ReadonlyArray<ReadT>>

Description

Query results are represented as a signal of a read-only collection containing all matched elements.

Further information is available in the Usage Notes...

Usage notes

Create a children query in your component by declaring a class field and initializing it with the contentChildren() function.

      
      @Component({...})
export class TestComponent {
  headerEl = contentChildren<ElementRef>('h');   // Signal<ReadonlyArray<ElementRef>>
}