非匹配的路由我在角2重定向角2
更多细节寻找的$urlRouterProvider.otherwise
相当于:
我有一个路由器的定义是这样的:
@RouteConfig([
{ path: "/", component: MultiPost, name: "Home", useAsDefault: true },
{ path: "/m/:collectionName/:categoryName/:page", component: MultiPost, name: "MultiPost" }
])
两条路线都完美运行,例如当我点击/
或/m/sth/sth/0
时,我得到了我想要的。
但是当我点击一个像/kdfsgdshdjf
这样的随机链接时,没有任何反应。由于没有路线匹配,页面呈现并且<router-outlet>
为空。
我想要做的是将所有不匹配的路由重定向到默认路由。我需要类似$urlRouterProvider.otherwise("/");
。
有谁知道该怎么做?
坏消息对我来说,但谢谢你让我知道。 –
是的,我也期待着这个,你仍然可以重定向到后端服务器。 – Langley
它现在被实现,可以像这样使用: const appRoutes:Routes = [ {path:'**',component:PageNotFoundComponent} ]; –