viewChildren
Initializer API
Initializes a view children query.
Query results are represented as a signal of a read-only collection containing all matched elements.
function viewChildren<LocatorT>(locator: string | ProviderToken<LocatorT>, opts?: { debugName?: string | undefined; } | undefined): Signal<readonly LocatorT[]>;@paramopts
{ debugName?: string | undefined; } | undefined@returns
Signal<readonly LocatorT[]>function viewChildren<LocatorT, ReadT>(locator: string | ProviderToken<LocatorT>, opts: { read: ProviderToken<ReadT>; debugName?: string | undefined; }): Signal<readonly ReadT[]>;@returns
Signal<readonly ReadT[]>Usage Notes
Create a children query in your component by declaring a
class field and initializing it with the viewChildren() function.
@Component({...})export class TestComponent { divEls = viewChildren<ElementRef>('el'); // Signal<ReadonlyArray<ElementRef>>}
Jump to details