Arias Dev Notes

Angular Signal Input

21st July 2024
Angular
angular
signals
Last updated:11th October 2026
1 Minutes
189 Words

Signal inputs let you get values from parent components. These values are shown using a Signal

  • Optional inputs: Inputs are optional by default unless you use input.required. You can provide an initial value, or Angular will use undefined by default.

  • Required inputs: Required inputs must always have a value of the specified input type. They are defined using the input.required function.

app-component.ts
import { Component, InputSignal, input } from '@angular/core';
@Component({
selector: 'app-root',
standalone: true,
template: `<div>
<p>Counter Value: {{ counter }}</p>
<p>Counter Value: {{ counter() }}</p>
<p>UserName Value: {{ userName }}</p>
<p>UserName Value: {{ userName() }}</p>
<p>LastName Value: {{ lastName }}</p>
<p>LastName Value: {{ lastName() }}</p>
</div>`,
})
export class AppComponent {
7 collapsed lines
@Input() counter: number | undefined;
counter: InputSignal<number | undefined> = input<number>();
@Input({ required: true }) userName!: string;
userName: InputSignal<string> = input.required<string>();
@Input() lastName: string = 'arias';
lastName: InputSignal<string> = input<string>('arias');
}

Input Alias

Angular uses the class member name as the input name by default. However, you can alias inputs to give them a different public name.

app-component.ts
import { Component, InputSignal, input } from '@angular/core';
@Component(/** ... */)
export class AppComponent {
name: InputSignal<string> = input<string>('andres', { alias: 'userName' });
}
root-component.html
<app-component [userName]="value" />
Article title:Angular Signal Input
Article author:Andrés Arias
Release time:21st July 2024