[英]Angular 4 dynamic page loader : ExpressionChangedAfterItHasBeenCheckedError
I'm using a css loader on my root app.component.html with a ngIf : 我在ngIf的根app.component.html上使用css加载器:
<div *ngIf="displayPageLoader" class="page-loader-background">
<div class="page-loader">
<div class="loader2" style="font-size: 7px; top: -50px;">Loading...</div>
</div>
</div>
When i need to display the loader, i'm calling the ToggleLoadersService service which tells the root component to change the variable displayPageLoader. 当我需要显示加载程序时,我正在调用ToggleLoadersService服务,该服务告诉根组件更改变量displayPageLoader。
It works well but i keep getting this error on pretty much every page : 它运作良好,但我几乎在每个页面上都收到此错误:
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.
at viewDebugError (vendor.bundle.js:8687)
at expressionChangedAfterItHasBeenCheckedError (vendor.bundle.js:8665)
at checkBindingNoChanges (vendor.bundle.js:8829)
at checkNoChangesNodeInline (vendor.bundle.js:12682)
at checkNoChangesNode (vendor.bundle.js:12656)
at debugCheckNoChangesNode (vendor.bundle.js:13431)
at debugCheckDirectivesFn (vendor.bundle.js:13333)
at Object.eval [as updateDirectives] (ng:///AppModule/AppComponent.ngfactory.js:50)
at Object.debugUpdateDirectives [as updateDirectives] (vendor.bundle.js:13315)
at checkNoChangesView (vendor.bundle.js:12476)
at callViewAction (vendor.bundle.js:12840)
Here's a scenario that toggles this error : 这是一个切换此错误的方案:
The error appears when the page 2 try to call the ToggleLoadersService service to toggle off the loader. 当页面2尝试调用ToggleLoadersService服务以关闭加载程序时,将出现错误。
I am aware that there are other related subjects but they are not really helping me. 我知道还有其他相关主题,但它们并没有真正帮助我。
Any help would be appreciated. 任何帮助,将不胜感激。 Thanks.
谢谢。
Try [hidden] as it only hide the element not remove it. 尝试[hidden],因为它仅隐藏元素而不删除它。 it will not create an event but will be only available to UI
它不会创建事件,但仅可用于UI
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.