版本“ @ angular / router”:“ ^ 3.3.1”
我只需要在我的app.route.ts中声明的路线名称
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { DeclarationsComponent } from './declarations/declarations.component';
const appRoutes: Routes = [
{ path: '', pathMatch: 'full', component: HomeComponent },
{ path: 'declarations', pathMatch: 'full', component: DeclarationsComponent }
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
在视图中,我只写了路线的名称
<ul class="nav navbar-nav">
<li routerLinkActive="active"><a routerLink="">Home</a></li>
<li><a routerLink="declarations">SAV</a></li>
</ul>