0 day streak
javascript / beginner
Snippet

Angular Signals

Signals are a reactive primitive in Angular that track state changes and trigger targeted UI updates efficiently.

snippet.js
javascript
1
2
3
4
5
count = signal(0);
increment() {
this.count.update(c => c + 1);
}
angular
Breakdown
1
count = signal(0);
Initializes a writable signal with an initial numeric value of 0.
2
this.count.update(c => c + 1);
Updates the signal value by applying a transformation function to its current state.