码迷,mamicode.com
首页 > 其他好文 > 详细

[Angular2 Router] Build Angular 2 Navigation with routerLink

时间:2016-09-25 06:11:01      阅读:168      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!