我正在使用Angular 2.0和路由器版本3.0.0。我已经定义了以下路由配置。
export const onlineRoutes: Routes = [
{ path: 'online.html', component:onlineHome },
{ path: 'portfolioperformance', component: PortfolioPerformance },
];
export const onlinerouting = RouterModule.forRoot(onlineRoutes,{useHash:false,enableTracing:true});
它成功路由到online.html路线但是当我尝试路由到' portfolioperformance'使用以下声明它不起作用。
this.router.navigate(['/portfolioperformance']);
如果我使用下面的路由器链接,点击链接就可以了。
<li><a [router-link]="['/portfolioperformance']">Start</a></li>
我启用了路由器跟踪,以下是路由跟踪详细信息。
‹Start group›: Router Event: NavigationStart
NavigationStart(id: 1, url: '/portfolioperformance')
NavigationStart {id: 1, url: "/portfolioperformance"}
‹End group›
‹Start group›: Router Event: NavigationStart
NavigationStart(id: 2, url: '/online.html#id_token=XXXXXXXXXXXXXXXXXXXXX"}
‹End group›
Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
‹Start group›: Router Event: NavigationCancel
NavigationCancel(id: 1, url: '/portfolioperformance')
NavigationCancel {id: 1, url: "/portfolioperformance", reason: "Navigation ID 1 is not equal to the current navigation id 2"}
‹End group›
‹Start group›: Router Event: RoutesRecognized
RoutesRecognized(id: 2, url: '/online.html#id_token=XXXXXXXXXXXX', state: Route(url:'', path:'') { Route(url:'online.html', path:'online.html') } )
无法弄清楚什么是错的。任何帮助表示赞赏。