2017-08-30 69 views
0

我在Angular 4中编写了一个自定义的404页面,并希望保留输入的错误url。 例如,你可以看到github上的行为。他们为不存在的网址显示404页面。例如:https://github.com/cdkdfjkdjfAngular:404页面但保留网址

目前我配置我的路由器是这样的:

{ path: '404', component: NotFoundComponent }, 
{ path: '**', redirectTo: '404' } 

任何想法如何存档呢?

+0

检查这个答案: https://stackoverflow.com/questions/36260839/angular-2-how-to-redirect-to-404-or-other -path-if-the-path-does-exist – SergioEscudero

+0

[Angular 2如何重定向到404或其他路径(如果路径不存在)](https://stackoverflow.com/questions/36260839/angular -2-如何到重定向到404-或-其他路径-IF-的路径此结果不同时存在) –

回答

0

的解决方案很简单:

{ path: '**', component: NotFoundComponent }