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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With