contentChild
Initializer API
Initializes a content child query. Consider using contentChild.required
for queries that should
always match.
function contentChild<LocatorT>(locator: string | ProviderToken<LocatorT>, opts?: { descendants?: boolean | undefined; read?: undefined; debugName?: string | undefined; } | undefined): Signal<LocatorT | undefined>;
Initializes a content child query.
Consider using contentChild.required
for queries that should always match.
@paramopts
{ descendants?: boolean | undefined; read?: undefined; debugName?: string | undefined; } | undefined
@returns
Signal<LocatorT | undefined>
function contentChild<LocatorT, ReadT>(locator: string | ProviderToken<LocatorT>, opts: { descendants?: boolean | undefined; read: ProviderToken<ReadT>; debugName?: string | undefined; }): Signal<ReadT | undefined>;
@paramopts
{ descendants?: boolean | undefined; read: ProviderToken<ReadT>; debugName?: string | undefined; }
@returns
Signal<ReadT | undefined>
function contentChild.required<LocatorT>(locator: string | ProviderToken<LocatorT>, opts?: { descendants?: boolean | undefined; read?: undefined; debugName?: string | undefined; } | undefined): Signal<LocatorT>;
@paramopts
{ descendants?: boolean | undefined; read?: undefined; debugName?: string | undefined; } | undefined
@returns
Signal<LocatorT>
function contentChild.required<LocatorT, ReadT>(locator: string | ProviderToken<LocatorT>, opts: { descendants?: boolean | undefined; read: ProviderToken<ReadT>; debugName?: string | undefined; }): Signal<ReadT>;
@paramopts
{ descendants?: boolean | undefined; read: ProviderToken<ReadT>; debugName?: string | undefined; }
@returns
Signal<ReadT>
Usage Notes
Create a child query in your component by declaring a
class field and initializing it with the contentChild()
function.
@Component({...})export class TestComponent { headerEl = contentChild<ElementRef>('h'); // Signal<ElementRef|undefined> headerElElRequired = contentChild.required<ElementRef>('h'); // Signal<ElementRef> header = contentChild(MyHeader); // Signal<MyHeader|undefined> headerRequired = contentChild.required(MyHeader); // Signal<MyHeader>}
Jump to details