In the component, I have a getter that looks like this:
public get canSave(): boolean {
const isValid = this.rows.every(r => r.phoneControl.valid);
if (!isValid) {
return false;
}
const changes = this.managePhonesPopupService.getChanges(this.rows, this.params);
return changes.phones.changed || changes.emergencyPhone.changed;
}
Now, in the onSubmitClick method, I need to update the value of this getter. Here is what I attempted:
public onSubmitClick(): void {
const changes = this.managePhonesPopupService.getChanges(this.rows, this.params);
this.canSave = false;
this.params
.onSubmit(changes)
.pipe(take(1))
.subscribe(() => {
this.close(true).then();
});
}
However, an error occurred:
Cannot assign to 'canSave' because it is a read-only property.
So, how can I update the value of canSave in the onSubmitClick method? Below is the complete code for the component:
export class ManagePhonesPopup extends DialogBaseComponent<Params, boolean> implements OnInit {
// Component properties and methods here