我有以下表達式,如果用戶是來賓:角2 RC5 router.navigate不工作
this.router.navigate(['/intro']);
在我app.component.ts ngOnInit()
方法。
我app.component.html有<router-outlet></router-outlet>
但是當我進入我的應用程序作爲嘉賓,不顯示IntroComponent
和URL沒有/intro
保持爲空。
怎麼了?
我app.routes.ts
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
{path:'intro',component: IntroComponent},
{path:'login',component: LoginComponent},
{path:'register', component: RegisterComponent}
];
您正在使用什麼版本的Angular?你有配置的路線嗎?您是否正確導入它們(取決於您擁有的版本)?我們需要更多信息來幫助您解決問題 –
路由已配置,RC.5。我添加了我的app.routes.ts,HomeCOmponent已加載儘管我正在使用this.router進行導航以引導 – TheUnreal
請將一個最簡單的示例粘貼到一個plunker中。 – mxii