angular - Angular2 Routing: what does it mean that it creates an instance of the component associated? -


i'm teaching myself angular2 , text i'm looking @ says:

the router locates or creates instance of component associated route, , component’s view displayed in location defined routeroutlet directive.

the code example:

import { component } 'angular2/core'; import {productlistcomponent} './products/product-list.component'; import {productservice} './products/product.service'; import {http_providers} 'angular2/http'; import {router_providers, routeconfig, router_directives} 'angular2/router'; import 'rxjs/rx'; //load features import {welcomecomponent} './home/welcome.component' @component({     selector: 'pm-app',     template:`     <div>         <nav class='navbar navbar-default'>             <div class='container-fluid'>                 <a class='navbar-brand'>{{pagetitle}}</a>                 <ul class='nav navbar-nav'>                     <li><a [routerlink]="['welcome']">home</a></li>                     <li><a [routerlink]="['products']">product list</a></li>                 </ul>             </div>         </nav>         <div class='container'>             <router-outlet></router-outlet>         </div>     </div>`,     directives: [router_directives],     providers: [productservice, http_providers, router_providers] }) @routeconfig([     {path: '/welcome', name: 'welcome', component: welcomecomponent, useasdefault: true },     {path: '/products', name: 'products', component: productlistcomponent} ]) export class appcomponent {     pagetitle: string = "acme product management"; } 

the question is: can see locate part mean creates instance of component associated? {} , if display in associated routeroutlet directive?

you have routeconfig annotation consist 2 config objects:

{path: '/welcome', name: 'welcome', component: welcomecomponent, useasdefault: true }, {path: '/products', name: 'products', component: productlistcomponent} 

each of object has it's own path /welcome , associated component welcomecomponent, instance.

if going /welcome location, angular put associated path component - welcomecomponent in place <router-outlet></router-outlet> directive included in html.

as result have injected component in it's own html , logic in specific place.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -