contentChildren
Initializer API
Initializes a content children query.
Query results are represented as a signal of a read-only collection containing all matched elements.
function contentChildren<LocatorT>(locator: string | ProviderToken<LocatorT>, opts?: { descendants?: boolean | undefined; read?: undefined; debugName?: string | undefined; } | undefined): Signal<readonly LocatorT[]>;
@paramopts
{ descendants?: boolean | undefined; read?: undefined; debugName?: string | undefined; } | undefined
@returns
Signal<readonly LocatorT[]>
function contentChildren<LocatorT, ReadT>(locator: string | ProviderToken<LocatorT>, opts: { descendants?: boolean | undefined; read: ProviderToken<ReadT>; debugName?: string | undefined; }): Signal<readonly ReadT[]>;
@paramopts
{ descendants?: boolean | undefined; read: ProviderToken<ReadT>; debugName?: string | undefined; }
@returns
Signal<readonly ReadT[]>
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>>}
Jump to details