首页 > 其他 > 详细

[Angular2 Router] Build Angular 2 Navigation with routerLink

时间:2016-09-25 06:09:57      阅读:142      评论:0      收藏:0      [点我收藏+]

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);

 

Github

[Angular2 Router] Build Angular 2 Navigation with routerLink

原文:http://www.cnblogs.com/Answer1215/p/5904814.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!