Search code examples
angularionic-frameworkionic4angular-template

ExpressionChangedAfterItHasBeenCheckedError Angular *ngIf directive couses error


I get the error mentioned in question title when I click a button that schuld toggle the component.

enter image description here

Here is the stackblitz example https://stackblitz.com/edit/ionic-v4-fbgbgf


Solution

  • I solved the issue by accessing the isFreeType value of a description FormGroup by using:

    description.get("isFreeType").value
    

    instead of

    description.value.isFreeType
    

    Furthermore, the approach that you used to set the value of the isFreeType FormControl was wrong; you cant do description.value.isFreeType.setValue, after accesing the value property, you are not manipulating an AbstractControl anymore, just a plain value.

    See the working demo in this blitz