Angular › Angular Signals
What is a signal in Angular and how does it help manage a component's data?
BeginnerAnswer
A signal is a wrapper around a value that notifies Angular exactly when that value changes, letting Angular update only the specific parts of the page that actually depend on it. You create a signal using the signal function, read its current value by calling it like a function, and update it using its set or update methods.
import { signal } from '@angular/core';
@Component({
selector: 'app-counter',
template: `<button (click)="increment()">Count: {{ count() }}</button>`
})
export class CounterComponent {
count = signal(0);
increment() { this.count.update((value) => value + 1); }
}Real-world example A counter component displays and updates its count using a signal, and Angular automatically knows exactly when to refresh just that piece of text on the screen, without needing to check the entire component for changes.