角9和角材质MatDialog“错误this.dialog未定义”

问题描述

在我的有角度的应用程序中,我尝试捕获并显示错误返回。 后面的调用在专用服务文件(quick-list.service.ts)中完成 后面的示例调用:

vnoremap <leader>dab "hy:v/<c-r>h/d<cr>
vnoremap <leader>daa "hy:g/<c-r>h/d<cr>

在同一文件中,我有一个方法(handleError)来捕获错误:

getSeries(): Observable<Object> {
    return this.httpClient.get('http://localhost:8080/serieselk/liste').pipe(
      catchError(this.handleError)
    ); 
}

使用此代码,出现“ this.dialog is undefined”错误,并且matDialog框不显示 在我的应用程序中,我对其他MatDialog框使用了相同的代码,效果很好。

在这种情况下,我尝试在“可注入服务”(quick-list.service.ts)中打开对话框,在另一种情况下(在可行的情况下)我在“ component”(seriedetails.component)中进行操作。 ts)

所以我的问题是,可以在此处使用MatDialog框吗?以及如何?

quick-list.service.ts:

private handleError(error: HttpErrorResponse) {
    if (error.error instanceof ErrorEvent) {
      // A client-side or network error occurred. Handle it accordingly.
      console.error('An error occurred:',error.error.message);
    } else {
      // The backend returned an unsuccessful response code.
      // The response body may contain clues as to what went wrong,console.error(
        `Backend returned code ${error.status},` +
        `body was: ${error.error.message}`);
    }
    //show error to user in a standard alert
    alert("test "+error.error.message);
    //try to show the error in a MatDialog box to replace the ugly default alert...
    var confdata: Confirmdiagdata = {boxtitre : "Erreur "+error.status,texte:error.error.message};
    this.dialog.open(ConfirmdiagComponent,{ //This line return the "this.dialog is undefined" error
      width: '25%',data: confdata
    });
    // return an observable with a user-facing error message
    return throwError(
      'Something bad happened; please try again later.');
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...