input
The input
function allows declaration of Angular inputs in directives
and components.
There are two variants of inputs that can be declared:
- Optional inputs with an initial value.
- Required inputs that consumers need to set.
By default, the input
function will declare optional inputs that
always have an initial value. Required inputs can be declared
using the input.required()
function.
Inputs are signals. The values of an input are exposed as a Signal
.
The signal always holds the latest value of the input that is bound
from the parent.
function input<T>(): InputSignal<T | undefined>;
Initializes an input of type T
with an initial value of undefined
.
Angular will implicitly use undefined
as initial value.
InputSignal<T | undefined>
function input<T>(initialValue: T, opts?: InputOptionsWithoutTransform<T> | undefined): InputSignal<T>;
Declares an input of type T
with an explicit initial value.
T
InputSignal<T>
function input<T>(initialValue: undefined, opts: InputOptionsWithoutTransform<T>): InputSignal<T | undefined>;
Declares an input of type T|undefined
without an initial value, but with input options
undefined
InputSignal<T | undefined>
function input<T, TransformT>(initialValue: T, opts: InputOptionsWithTransform<T, TransformT>): InputSignalWithTransform<T, TransformT>;
Declares an input of type T
with an initial value and a transform
function.
The input accepts values of type TransformT
and the given
transform function will transform the value to type T
.
T
InputSignalWithTransform<T, TransformT>
function input<T, TransformT>(initialValue: undefined, opts: InputOptionsWithTransform<T | undefined, TransformT>): InputSignalWithTransform<T | undefined, TransformT>;
Declares an input of type T|undefined
without an initial value and with a transform
function.
The input accepts values of type TransformT
and the given
transform function will transform the value to type T|undefined
.
undefined
InputSignalWithTransform<T | undefined, TransformT>
function input.required<T>(opts?: InputOptionsWithoutTransform<T> | undefined): InputSignal<T>;
Declares a required input of type T
.
InputSignal<T>
function input.required<T, TransformT>(opts: InputOptionsWithTransform<T, TransformT>): InputSignalWithTransform<T, TransformT>;
Declares a required input of type T
with a transform function.
The input accepts values of type TransformT
and the given
transform function will transform the value to type T
.
InputSignalWithTransform<T, TransformT>