0
私のアプリケーションにはデフォルトのエラーページがあります。 デフォルトのエラーページ:angular2
import { ErrorHandler, Injectable, Injector } from '@angular/core';
import { Router } from '@angular/router';
@Injectable()
export class GlobalErrorHandler implements ErrorHandler {
router: Router;
constructor(private injector: Injector) {
this.router = this.injector.get(Router);
}
handleError(error) {
this.router.navigate(['error']);
throw error;
}
}
と同様のエラーページの構成要素とルートを作成します:それを達成するために、私は、エラーハンドラを実装
export const routes: Routes = [
{ path: '', component: RecipeListComponent },
...
{ path: 'error', component: ErrorPageComponent }
];
が、この行を、エラーHadler博士では動作しません...誰かが持っています理由についてのいくつかのアイデア?
this.router.navigate(['error']);
エラーが発生しましたが、エラーページにルーティングできません。子ルートがpathMatch: 'full'
{ path: '', component: RecipeListComponent, pathMatch: 'full' },
必要がある空のパス''
と