Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/148.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular Ngonit中的ExpressionChangedTerithasBeenCheckedError_Angular - Fatal编程技术网

Angular Ngonit中的ExpressionChangedTerithasBeenCheckedError

Angular Ngonit中的ExpressionChangedTerithasBeenCheckedError,angular,Angular,我让我的HTTP拦截器在每次发出HTTP请求时打开加载栏: intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { const dataStorageService = this.injector.get(DataStorageService); dataStorageService.openProgressbar.next(true);

我让我的HTTP拦截器在每次发出HTTP请求时打开加载栏:

intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    const dataStorageService = this.injector.get(DataStorageService);
    dataStorageService.openProgressbar.next(true);
    return next
        .handle(req)
        .do(evt => {
             if (evt instanceof HttpResponse) {
                 dataStorageService.openProgressbar.next(false);
            }
        })
        .catch(err => {
            return Observable.throw(err);
        });
    }
我在我的应用程序组件中收听它,我在其中放置了加载栏:

ngOnInit() {
    this.dataStorageService.openProgressbar.subscribe(czyOtworzyc => {
        this.alertMessageNavbarStatus = true;
    });
}
但是将显示
表达式ChangedTerithasBeenCheckedError
。 我一直在寻找使用ngAfterContentChecked的解决方案,但它对我不起作用。有人能帮我吗?

注入组件

import { ChangeDetectorRef } from '@angular/core';

constructor(private _changeDetectorRef: ChangeDetectorRef) {}
手动运行更改检测

ngOnInit() {
    ...
    this._changeDetectorRef.detectChanges();
}
注入组件中

import { ChangeDetectorRef } from '@angular/core';

constructor(private _changeDetectorRef: ChangeDetectorRef) {}
手动运行更改检测

ngOnInit() {
    ...
    this._changeDetectorRef.detectChanges();
}

手动使用detectchanges手动使用detectchanges手动我添加了此项。_changeDetectorRef.detectchanges();结束我的ngoninit但仍然得到错误OK我发现了:ngAfterContentChecked(){this.\u changedtectorref.detectChanges();}我添加了这个。_changedtectorref.detectChanges();结束我的ngoninit但仍然得到错误OK我发现了:ngAfterContentChecked(){this.\u changeDetectorRef.detectChanges();}