41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
// #docplaster
|
|
// #docregion
|
|
import { Component } from 'angular2/core';
|
|
|
|
// Can't test with ROUTER_DIRECTIVES yet
|
|
// import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router';
|
|
|
|
import { RouteConfig, RouterLink,
|
|
RouterOutlet, ROUTER_PROVIDERS } from 'angular2/router';
|
|
|
|
import { DashboardComponent } from './dashboard.component';
|
|
import { HeroesComponent } from './heroes.component';
|
|
import { HeroDetailComponent } from './hero-detail.component';
|
|
import { HeroService } from './hero.service';
|
|
|
|
@Component({
|
|
selector: 'my-app',
|
|
template: `
|
|
<h1>{{title}}</h1>
|
|
<nav>
|
|
<a [routerLink]="['Dashboard']">Dashboard</a>
|
|
<a [routerLink]="['Heroes']">Heroes</a>
|
|
</nav>
|
|
<router-outlet></router-outlet>
|
|
`,
|
|
styleUrls: ['app/app.component.css'],
|
|
directives: [RouterLink, RouterOutlet],
|
|
providers: [
|
|
ROUTER_PROVIDERS,
|
|
HeroService
|
|
]
|
|
})
|
|
@RouteConfig([
|
|
{ path: '/dashboard', name: 'Dashboard', component: DashboardComponent, useAsDefault: true },
|
|
{ path: '/detail/:id', name: 'HeroDetail', component: HeroDetailComponent },
|
|
{ path: '/heroes', name: 'Heroes', component: HeroesComponent }
|
|
])
|
|
export class AppComponent {
|
|
title = 'Tour of Heroes';
|
|
}
|