我尝试按照此tutorial向我的angualr2应用添加引导导航栏。
我已经从angular2 quick start页面创建了我的应用。
最好是重新开始使用found
?
但是我发现在angular2 RC中不推荐使用lib angular2 CLI bootstrap
。
是否有适用于angualr2的简单模板\教程?
答案 0 :(得分:1)
Angular2RC5中使用路由器的方式发生了变化。
如果您想从RC4迁移到RC5,可以阅读官方文档(https://angular.io/docs/ts/latest/cookbook/rc4-to-rc5.html)。
新的使用方式路由器如下(来自官方文档 - https://angular.io/docs/ts/latest/guide/router.html):
app.routing.ts
import { Routes, RouterModule } from '@angular/router';
const appRoutes: Routes = [
{ path: 'crisis-center', component: CrisisCenterComponent },
{
path: 'heroes',
component: HeroListComponent,
data: {
title: 'Heroes List'
}
},
{ path: 'hero/:id', component: HeroDetailComponent },
{ path: '**', component: PageNotFoundComponent }
];
export const appRoutingProviders: any[] = [
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
app.module.ts
import { AppComponent } from './app.component';
import { routing,
appRoutingProviders } from './app.routing';
import { HeroListComponent } from './hero-list.component';
import { CrisisListComponent } from './crisis-list.component';
@NgModule({
imports: [
BrowserModule,
FormsModule,
routing
],
declarations: [
AppComponent,
HeroListComponent,
CrisisListComponent
],
providers: [
appRoutingProviders
],
bootstrap: [ AppComponent ]
})