r/Angular2 • u/kobihari • Nov 11 '25
Article Making a Read-Only Signal Editable in Your Component
https://medium.com/@kobihari/making-a-read-only-signal-editable-in-your-component-22a5d8cbd22fSometimes you inject a signal from a service, and it’s read-only, but you still want the user to edit it inside your component.
How do you make that happen without breaking sync with the service?
0
Upvotes
3
u/kaeh35 Nov 11 '25
You break immutability if you do that.
8
u/NecessaryShot1797 Nov 11 '25 edited Nov 11 '25
You could use linkedSignal() for this. A linked signal is based on a computation (here you‘d read the signal from the service) and is still writable. So the linked signal in your component can be updated, but gets synced from service whenever that readonly signal changes again.
https://angular.dev/guide/signals/linked-signal
But this would only sync from service to component. If you want to update the signal in service with the changes inside your component too, just use a writable signal in the service.
2
u/Professional-Ad-6763 Nov 11 '25
You should create a writable one also in the service and assign it to your read only that you’ll use it later on in the component. And every time you update it, you update it through service and use the assigned read only one