简体   繁体   English

ExpressionChangedAfterItHasBeenCheckedError角度* ngIf指令引起错误

[英]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 这是stackblitz示例https://stackblitz.com/edit/ionic-v4-fbgbgf

I solved the issue by accessing the isFreeType value of a description FormGroup by using: 我通过使用以下isFreeType访问描述FormGroupisFreeType值解决了该问题:

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; 此外,您用来设置isFreeType FormControl值的isFreeType是错误的。 you cant do description.value.isFreeType.setValue , after accesing the value property, you are not manipulating an AbstractControl anymore, just a plain value. 您不能执行description.value.isFreeType.setValue ,在访问value属性后,您将不再操纵一个AbstractControl ,而只是一个普通值。

See the working demo in this blitz 观看这场闪电战中的工作演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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