Angular 2 rout config

angular 2 route-config

Search Keywords :-

[Angular 2 router link directive,  Angular 2 router-outlet directive,  Angular 2 rout-config , Angular 2 RouteParams]

For live example, go to plnkr http://embed.plnkr.co/vjf9Zz/

The Route-Config :-  The route config  is used to map components to URLs.

Syntax :-

 @RouteConfig([
        {path: '/',        component: Home_Component, as'Home'},
        {path: '/AboutMe', component: AboutMe_Component, as'AboutMe'  }
        {path: '/ContactMe', component: ContactMe_Component, as'ContactMe'  }
    ])

The Route Params :- The route parameter  is used to map given URL's parameters based on the rout URLs and It is an optional parameters for that route.

Syntax :-

             params : {[key: string]: string}

Example,

@RouteConfig([
         {path: '/employ/:id', component: employe, name: 'emp'},
])


Router-outlet directive :- Router-outlet directive is used to render the components for specific location of your applications. Both the template and templateUrl render the components where you use this directive.

Syntax :-

 <router-outlet></router-outlet>



Router-link directive :- Router-link directive is used to link a specific parts of your applications.

Syntax :-

 <router-link></router-link>

Example,

<a [router-link]="['/AboutMe']">About Me</a>


The live demo example, go to plnkr http://embed.plnkr.co/vjf9Zz/

ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.