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.

InputFunction

The input function allows declaration of inputs in directives and components.

See more...

      
      interface InputFunction {
  required: {...}
<T>(): InputSignal<T | undefined>
<T>(initialValue: T, opts?: InputOptionsWithoutTransform<T>): InputSignal<T>
<T, TransformT>(initialValue: T, opts: InputOptionsWithTransform<T, TransformT>): InputSignalWithTransform<T, TransformT> }

Description

The function exposes an API for also declaring required inputs via the input.required function.

Properties

Property Description
required: { <T>(opts?: InputOptionsWithoutTransform<T>): InputSignal<T>; <T, TransformT>(opts: InputOptionsWithTransform<T, TransformT>): InputSignalWithTransform<T, TransformT>; }

Initializes a required input.

Consumers of your directive/component need to bind to this input. If unset, a compile time error will be reported.

Methods

Initializes an input of type T with an initial value of undefined. Angular will implicitly use undefined as initial value.

      
      <T>(): InputSignal<T | undefined>
    
Parameters

There are no parameters.

Returns

InputSignal<T | undefined>

Declares an input of type T with an explicit initial value.

      
      <T>(initialValue: T, opts?: InputOptionsWithoutTransform<T>): InputSignal<T>
    
Parameters
initialValue T
opts InputOptionsWithoutTransform<T>

Optional. Default is undefined.

Returns

InputSignal<T>

Declares an input of type T with an initial value and a transform function.

      
      <T, TransformT>(initialValue: T, opts: InputOptionsWithTransform<T, TransformT>): InputSignalWithTransform<T, TransformT>
    
Parameters
initialValue T
opts InputOptionsWithTransform<T, TransformT>
Returns

InputSignalWithTransform<T, TransformT>

The input accepts values of type TransformT and the given transform function will transform the value to type T.