WHy am I getting the error: NG0600: Writing to signals is not allowed in a `computed`.
yet I am using a writable signal?
Below is the code
dialog = signal(false)
openDialog(action: 'edit' | 'create') {
this.dialog.update(action => action = !action)
return action
}
WHy am I getting the error: NG0600: Writing to signals is not allowed in a `computed`.
yet I am using a writable signal?
Below is the code
dialog = signal(false)
openDialog(action: 'edit' | 'create') {
this.dialog.update(action => action = !action)
return action
}
Share
Improve this question
edited Feb 6 at 8:28
Naren Murali
56.8k5 gold badges40 silver badges71 bronze badges
asked Feb 6 at 6:51
kibetkibet
3793 silver badges10 bronze badges
1 Answer
Reset to default 1The syntax is wrong, it should be an arrow function which returns the new value, what is written is an assignment operation instead (action = !action
).
The equality written might be causing NG0600: Writing to signals is not allowed in a computed
, because you are setting a value inside the update callback.
Another big problem is, both the argument and the update argument of the arrow function are named action
, so for better readability I renamed the first top argument to actionParam
instead.
dialog = signal(false)
openDialog(actionParam: 'edit' | 'create') {
this.dialog.update(action => !action)
return actionParam;
}