Angular · Middle · Question 62 of 75
How do you expose a signal from a service without letting components change it?
private readonly _items = signal<Item[]>([]);
readonly items = this._items.asReadonly();- ✓Correct answer: Keep a private writable signal and expose
asReadonly() - 2Mark the signal
public - 3Signals can't be shared through services
Explanation
Components read items(), and changes go through the service's methods. This keeps updates in one place.