当我尝试向构造函数添加可选参数时,出现此错误。我添加了应用程序模块来处理整个应用程序中的全局错误。使用rjxs抛出在httpclient上发生的错误
import { ErrorHandler, Injectable } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
@Injectable()
export class AppError implements ErrorHandler
{
//public snackBar: MatSnackBar;
// public orignalErr?: any
constructor (public orignalErr?: any){}
handleError()
{
// this.snackBar.open("Contact Administrator" + this.orgionalErr);
console.error (this.orignalErr)
}
}
ngOnInit()
{
this.gitService.getGitData().subscribe((response : GithubUser) => {
//this.gitLinks = Array.from(Object.keys(response), k=>response[k])
//console.warn("ngOnInit..." + this.gitLinks[1].login);
this.gitLinks = response;},(error) => {throw throwError(error)}
);
}
}
App module: to handle global error
{ provide: ErrorHandler, useClass : AppError }
预先感谢...
干杯湿婆