Well, if your template is part of another component, call it, NavigationComponent, which has a “navigation component” selector, then you can add this tag to your ng2-show-app template and add the navigation component as a directive ...
import {Component} from 'angular2/core'; import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router'; import {NavigationComponent} from 'src/navigationComponent'; @Component({ selector: 'ng2-showroom-app', providers: [], templateUrl: 'app/views/ng2-showroom-template.html', directives: [ROUTER_DIRECTIVES, NavigationComponent], pipes: [] }) @RouteConfig([ ]) export class Ng2Showroom { }
<navigation-component></navigation-component> <p> Hello World </p> <router-outlet></router-outlet>
But I guess what you're really going to use is the more common HTML homepage script, which is always there, and then the template, which will change based on navigation ...
import {Component} from 'angular2/core'; import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router'; import {Page1Component} from 'src/page1component'; import {Page2Component} from 'src/page2component'; @Component({ selector: 'ng2-showroom-app', providers: [], templateUrl: 'app/views/ng2-showroom-template.html', directives: [ROUTER_DIRECTIVES], pipes: [] }) @RouteConfig([ { path: '/page1', as: 'Page1', component: Page1Component }, { path: '/page2', as: 'Page2', component: Page2Component }]) export class Ng2Showroom { }
<p>HTML always shown above content, regardless of navigation.</p> <a [routerLink]="['Page1']">Link to Page 1</a> <a [routerLink]="['Page2']">Link to Page 2</a> <router-outlet></router-outlet> <p>HTML always shown below content.</p>
Now, when they click on the link "Link to Page 1", everything that you defined in Page1Component will be displayed inside the <router-outlet>
placeholder.