我在对话框组件中有一个微调器,要在执行http请求之前和之后显示该对话框,该对话框按预期方式打开和关闭,但是它始终在我在handle.pipe中截取的请求响应中引发ExpressionChangedAfterItHasBeenCheckedError
@Injectable()
export class ApiHttpInterceptor implements HttpInterceptor {
constructor(private router: Router, private sessionService: SessionService, private dialog: MatDialog) {}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const spinner = this.dialog.open(SpinnerDialogComponent, {
disableClose: true,
autoFocus: true,
width: '150px',
height: '150px',
panelClass: 'spinner'});
...
const authReq = req.clone({ headers: headers});
return next.handle(authReq).pipe(tap(
(event: HttpEvent<any>) => {
if (event instanceof HttpResponse) {
spinner.close();
}
return event;
}));
}
}
我正在使用angular6
我该如何解决?