WritableSignal.set()
Replaces a writable signal's value with a new value.
Syntax
set(value: T): void Parameters
| Name | Type | Required | Description |
|---|---|---|---|
value | T | No | The new value to store in the signal. |
Returns
void — Nothing; consumers are notified if the value changed.
Examples
import { signal } from '@angular/core';
const name = signal('Ada');
name.set('Grace');
console.log(name()); // 'Grace'
Notes
set() assigns a completely new value. Notification is skipped when the new
value is equal to the previous one per the signal's equal function (default
is Object.is). For object signals, replace the reference rather than mutating
in place so equality detects the change.