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