Signals
Use signals for fine-grained reactivity and computed state.
What you will be able to do
- Create signals with signal().
- Derive with computed().
- Update with set() or update().
- Use effect sparingly for side effects.
In plain English
A signal is a reactive value with explicit reads and writes. computed derives from signals, and effect runs side effects. Signals make dependencies visible to the compiler and reduce change-detection work.
import { Component, computed, signal } from '@angular/core'
@Component({
selector: 'app-counter',
standalone: true,
template: `
<button (click)="increment()">Clicked {{ count() }} times</button>
<p>Double: {{ double() }}</p>
`,
})
export class CounterComponent {
count = signal(0)
double = computed(() => this.count() * 2)
increment() { this.count.update((value) => value + 1) }
}Your turn
EasyDerive a total
Create a computed signal that doubles a count signal.
TYPESCRIPT · starter
double = computed(() => count)Check your understanding before moving on.
Knowledge checkQuestion 1
How do you read a signal in a template?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.