Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

typescript - Angular 2 router examples + @Routes typing support

I am trying to find a concrete example on how to use the router in Angular 2. Furthermore the current angular2.d.ts typing file from the 5 min quickstart does not support @Routes annotation.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Main component and Class of Routing in Angular 2.

router-link – router-link directive is use to declare link into view . Its can contains optional parameters also.

Example :

<a [router-link]="['/AboutUs']">About Us</a>

router-outlet – Its work as a placeholder for views to render then component. Means template and templateUrl will be render on that location where you will use router-outlet directive.

Example :

<router-outlet></router-outlet>

@RouteConfig – We map URLs to components in this section which used inside the .

Example :

@RouteConfig([
    {path: '/',        component: HomeComponent, as: 'Home'},
    {path: '/aboutus', component: AboutUsComponent, as: 'AboutUs'  }
    {path: '/contactus', component: ContactUsComponent, as: 'ContactUs'  }
])

RouteParams – Parameter to a component which rendered by the router.

Read this article for more http://www.codeandyou.com/2015/11/understand-routing-in-angular-2.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...