Create an Angular Computed Signal Which Depends on Another Signal

InstructorTomasz Ducin

Share this video with your friends

Send Tweet

Computed signals in Angular allow for the creation of derived values based on existing signals. By defining a new property and assigning it a computed signal, you can perform calculations or transformations on top of an existing signal's value.

To create a computed signal that remains responsive to changes in its dependencies, it's essential to:

  • Define the computed signal's callback function, which calculates the derived value based on other signals
  • Ensure that the computed signal is consumed by a live consumer, such as a template, to trigger re-evaluation when dependencies change

The reactivity flow in Angular ensures that whenever a dependency of a computed signal changes, the computed value is automatically re-evaluated. This re-evaluation only occurs if there is a live consumer, such as a template, that depends on the computed signal.