标签:
Angular 2 navigation is configured using the routerLink
directive. The routerLink directive behaves like an href’s you are familiar with, but it hooks into Angular 2’s router to navigate between your defined routes.
app.component.html:
<nav> <a routerLink="">Home</a> <a routerLink="contact">Contact</a> </nav> <router-outlet></router-outlet>
app.routers.ts:
import {HomeComponent} from "./home/home.component"; import {RouterModule} from "@angular/router"; import {ContactComponent} from "./contact/contact.component"; const routes = [ {path: ‘‘, component: HomeComponent}, {path: ‘contact‘, component: ContactComponent}, ]; export default RouterModule.forRoot(routes);
[Angular2 Router] Build Angular 2 Navigation with routerLink
标签:
原文地址:http://www.cnblogs.com/Answer1215/p/5904814.html