.otherwise或/ **在新的Angular2路由器通过通配符路由非路由

问题描述:

如何在新路由器中给出非功能路由时使用通配符路由...如同其他路由器。 1.X路由器或/ **在以前的测试版路由器中?任何示例/ plnkr代码是高度赞赏.otherwise或/ **在新的Angular2路由器通过通配符路由非路由

import { provideRouter, RouterConfig } from '@angular/router'; 

    const routes: RouterConfig = [ 
     { path: '**', component: PageNotFoundComponent } 
    ]; 

    export const appRouterProviders = [ 
     provideRouter(routes) 
    ]; 

的**表示用于我们的路线通配符路径。如果请求的URL不匹配我们配置中定义的路由的任何 路径,则 路由器将匹配此路由。这对于 显示404页面或重定向到其他路线很有用。

看看路由器docs

+0

的信息可以更准确地发现了[配置部分(https://angular.io/docs/ts/latest/guide/router.html#配置文档链接提供的链接以及[RouterConfig API](https://angular.io/docs/ts/latest/api/router/index/RouterConfig-type-alias.html#wild-卡)文档页面。 – edmundo096