viewChildren
Initializes a view children query.
viewChildren(locator: string | ProviderToken<LocatorT>): Signal<ReadonlyArray<LocatorT>>
Parameters
locator
|
string | ProviderToken<LocatorT> |
Returns
Signal<ReadonlyArray<LocatorT>>
viewChildren(locator: string | ProviderToken<LocatorT>, opts: { 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 viewChildren()
function.
@Component({...})
export class TestComponent {
divEls = viewChildren<ElementRef>('el'); // Signal<ReadonlyArray<ElementRef>>
}