简体   繁体   中英

ExpressionChangedAfterItHasBeenCheckedError Angular *ngIf directive couses error

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

在此处输入图片说明

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM