I am having a bit of trouble understanding the logic here
root-component
import { Component } from "angular2/core";
import { TopNavigationComponent } from "./shared/navigation.component";
import { ArcListComponent } from "./arc/arc-list.component";
import { ArcNewItemComponent } from "./arc/arc-new-item.component";
import { RouteConfig } from "angular2/router";
import { ROUTER_DIRECTIVES } from "angular2/router";
@Component({
selector: "ng2-app",
template: `
<section class="jumbotron full-height">
<top-navigation></top-navigation>
<div class="container">
<router-outlet></router-outlet>
</div>
</section>
`,
directives: [TopNavigationComponent, ArcListComponent,ROUTER_DIRECTIVES]
})
@RouteConfig([
{path: "/", name: "Root", component: ArcListComponent, useAsDefault: true},
{path: "/new", name: "New-item", component: ArcNewItemComponent}
])
export class RootComponent {
}
top-navigation component
import { Component } from "angular2/core";
import { ROUTER_DIRECTIVES } from "angular2/router";
@Component({
selector: "top-navigation",
templateUrl: "dev/shared/navigation.template.html",
directives: [ROUTER_DIRECTIVES]
})
export class TopNavigationComponent {
}
navigation.template
<nav class="navbar navbar-default">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" [routerLink]="['Root']">Angular2Arc</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><a [routerLink]="['Root']">Home</a></li>
<li><a [routerLink]="['New-item']">Add New Resource</a></li>
<li><a href="#">Github</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
my question is while this works, can you explain why i need to put Router directives in two places, and if there is a better way to do this?