0Pricing
Angular Academy · Lesson

Signal Stores in Services

Hold app state in signal-based services.

Signals as State

Angular signals are reactive values that notify consumers when they change. A signal holds a value and re-runs any computation or template that reads it.

Storing signals inside an @Injectable service lets multiple components share the same reactive state.

A Minimal Signal Store

Create a service and hold the state in a signal(). Keep the writable signal private and expose a read-only view.

import { Injectable, signal } from '@angular/core';

@Injectable({ providedIn: 'root' })
export class CounterStore {
  private _count = signal(0);
  readonly count = this._count.asReadonly();

  increment() { this._count.update(c => c + 1); }
}

All lessons in this course

  1. Signal Stores in Services
  2. Deriving State with computed
  3. Updating State Immutably
  4. Connecting Signals and RxJS
← Back to Angular Academy