Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use Angular’s linkedSignal when a value should normally be derived from other state but must also allow direct writes. Unlike computed, it is writable; unlike an independent signal, its value can be reset by a reactive computation when its dependencies change. Angular marks the API stable since v20.0, so check your project’s installed Angular version before using it.

What linkedSignal does

A linkedSignal is writable reactive state initialized and reset by a computation. It is useful when a derived value needs to allow an override between recomputations—for example, a notification preference that defaults to whether a user is online but can be manually changed.

In the simple form, pass a computation that reads other signals:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { linkedSignal, signal } from '@angular/core';

const userStatus = signal<'online' | 'away' | 'offline'>('offline');
const notificationsEnabled = linkedSignal(() => userStatus() === 'online');

notificationsEnabled.set(true); // A manual override is allowed
userStatus.set('online');       // The linked computation can re-sync the value

This follows Angular’s notification example: replacing a read-only computed flag with linkedSignal makes it possible to call .set() while still responding to status changes.

Choose the signal API that matches the ownership of the value

Need Angular API Behavior
Independent state that application code writes signal Stores a writable value.
A value derived from dependencies that must not be manually changed computed Provides a read-only derived value.
A derived value that must also allow writes linkedSignal Provides writable state that remains reactively linked.
Synchronization with an imperative or non-signal system effect Runs side effects; it is not intended for copying derived state.

Angular describes computed signals as read-only and derived from dependencies. Use computed if callers should never override the result. Angular’s effects guidance recommends effects for synchronizing with imperative APIs and other side effects, not for mirroring one signal into another.

Preserve a selection when its available options change

When a list of choices changes, resetting the selection to the first item every time can discard a still-valid user choice. The source-and-computation form lets the computation inspect the new source and the previous source and linked value, then keep the old choice if it remains valid or select a suitable fallback.

linkedSignal({
  source: options,
  computation: (newOptions, previous) => {
    const previousSelection = previous?.value;
    return previousSelection && newOptions.includes(previousSelection)
      ? previousSelection
      : newOptions[0];
  },
});

This illustrates the decision pattern; adapt the types and empty-list behavior to your application. In Angular’s linkedSignal guide, the computation receives the new source and a previous object with the prior source and linked value. The API reference documents the source/computation overload.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When to use linkedSignal—and when not to

  • Use it when the value has a reactive default but a user or other caller may need to change it directly.
  • Use the previous-aware form when the source can change and you want to retain a prior value only if it remains valid.
  • Use computed when the value is purely derived and manual writes should be impossible.
  • Use signal when the value is independent rather than derived from other signals.
  • Use effect when you need to synchronize with an imperative system, not merely copy derived state.

Angular’s guide also shows custom equality comparison and an optional custom set operation. A custom setter can route writes to a source of truth, but use it deliberately: make clear which state owns the value and where a write takes effect.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check version and syntax before adopting it

Angular’s official API reference labels linkedSignal stable since v20.0. Confirm the Angular version installed in your application and use documentation that matches that release; the guide at next.angular.dev describes next-version documentation, so its exact syntax may differ from an older project’s API.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.