input • Angular

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

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

Declares an input of type T|undefined without an initial value, but with input options

@paraminitialValueundefined

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.

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.

@paraminitialValueundefined

Declares a required input of type T.

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.

Usage Notes

To use signal-based inputs, import input from @angular/core.

import {input} from '@angular/core';

Inside your component, introduce a new class member and initialize it with a call to input or input.required.

@Component({  ...})export class UserProfileComponent {  firstName = input<string>();             // Signal<string|undefined>  lastName  = input.required<string>();    // Signal<string>  age       = input(0)                     // Signal<number>}

Inside your component template, you can display values of the inputs by calling the signal.

<span>{{firstName()}}</span>