mercredi 21 juin 2023

Updating checkbox's checked status from parent - Angular

I'm trying to create a reusable switcher component whose state won't be changed immediately when clicked, but after an API call is made in parent component - if there is no error, the state will be changed, while when there is an error, the state will remain unchanged.

The problem occurs when the checkbox state is updated from the parent level, the @Input value is updated correctly, but the checkbox state remains unchanged.

Simple reproduction of the problem at the link below: stackblitz-checkbox-issue

I tried to use ChangeDetectorRef after updating the @Input value, ngModel bindinig, but to no avail.

Any ideas what to do to update the checkbox state from the parent level to work properly?




Aucun commentaire:

Enregistrer un commentaire