简体   繁体   English

Angular 4动态页面加载器:ExpressionChangedAfterItHasBeenCheckedError

[英]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 : 这是一个切换此错误的方案:

  • User is on page 1. 用户在第1页。
  • User clicks page 2 button : The page 1 component calls the ToggleLoadersService service to toggle on the loader and then redirects the user to page 2. 用户单击页面2按钮:页面1组件调用ToggleLoadersService服务以切换加载程序,然后将用户重定向到页面2。
  • User arrives on page 2. 用户到达第2页。
  • the page 2 calls the ToggleLoadersService service to toggle off the loader. 第2页调用ToggleLoadersService服务以关闭加载程序。

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.

相关问题 角动态组件和ExpressionChangedAfterItHasBeenCheckedError - Angular Dynamic Components and ExpressionChangedAfterItHasBeenCheckedError 由于角度6中的加载器拦截器,导致ExpressionChangedAfterItHasBeenCheckedError错误 - ExpressionChangedAfterItHasBeenCheckedError error because of loader interceptor in angular 6 Angular动态组件加载 - ExpressionChangedAfterItHasBeenCheckedError - Angular dynamic component loading - ExpressionChangedAfterItHasBeenCheckedError 动态组件中的 Angular ExpressionChangedAfterItHasBeenCheckedError - Angular ExpressionChangedAfterItHasBeenCheckedError inside Dynamic Components Angular中动态模板管理期间的ExpressionChangedAfterItHasBeenCheckedError - ExpressionChangedAfterItHasBeenCheckedError during dynamic template management in Angular 在 angular 8, ExpressionChangedAfterItHasBeenCheckedError 页面加载后触发 animation - Trigger animation after page load in angular 8, ExpressionChangedAfterItHasBeenCheckedError ExpressionChangedAfterItHasBeenCheckedError:角度 - ExpressionChangedAfterItHasBeenCheckedError: angular ExpressionChangedAfterItHasBeenCheckedError Angular - ExpressionChangedAfterItHasBeenCheckedError Angular Angular 4 ExpressionChangedAfterItHasBeenCheckedError - Angular 4 ExpressionChangedAfterItHasBeenCheckedError Angular 2动态标签加载器 - Angular 2 dynamic tabs loader
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM