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.

ContentChildFunction

Type of the contentChild function.

See more...

      
      interface ContentChildFunction {
  required: {...}
<LocatorT>(locator: string | ProviderToken<LocatorT>, opts?: { descendants?: boolean; read?: undefined; }): Signal<LocatorT | undefined>
<LocatorT, ReadT>(locator: string | ProviderToken<LocatorT>, opts: { descendants?: boolean; read: ProviderToken<ReadT>; }): Signal<ReadT | undefined> }

Description

The contentChild function creates a singular content query. It is a special function that also provides access to required query results via the .required property.

Properties

Property Description
required: { <LocatorT>(locator: ProviderToken<LocatorT> | string, opts?: { descendants?: boolean; read?: undefined; }): Signal<LocatorT>; <LocatorT, ReadT>(locator: ProviderToken<LocatorT> | string, opts: { descendants?: boolean; read: ProviderToken<ReadT>; }): Signal<ReadT>; }

Initializes a content child query that is always expected to match.

Methods

Initializes a content child query.

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

Optional. Default is undefined.

Returns

Signal<LocatorT | undefined>

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

Signal<ReadT | undefined>

Consider using contentChild.required for queries that should always match.