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.

ViewChildFunction

Type of the viewChild function. The viewChild function creates a singular view query.

See more...

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

Description

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): Signal<LocatorT>; <LocatorT, ReadT>(locator: ProviderToken<LocatorT> | string, opts: { read: ProviderToken<ReadT>; }): Signal<ReadT>; }

Initializes a view child query that is expected to always match an element.

Methods

Initializes a view child query. Consider using viewChild.required for queries that should always match.

      
      <LocatorT>(locator: string | ProviderToken<LocatorT>): Signal<LocatorT | undefined>
    
Parameters
locator string | ProviderToken<LocatorT>
Returns

Signal<LocatorT | undefined>

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

Signal<ReadT | undefined>