angular-docs-cn/public/docs/_examples/toh-5/ts/app/app.component.2.ts

41 lines
946 B
TypeScript
Raw Normal View History

2015-12-23 12:42:57 -05:00
// #docplaster
// #docregion
2016-04-27 14:28:22 -04:00
import { Component } from '@angular/core';
2015-12-23 12:42:57 -05:00
// #docregion import-router
2016-04-27 14:28:22 -04:00
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from '@angular/router-deprecated';
2015-12-23 12:42:57 -05:00
// #enddocregion import-router
import { HeroService } from './hero.service';
import { HeroesComponent } from './heroes.component';
@Component({
selector: 'my-app',
// #docregion template
template: `
<h1>{{title}}</h1>
<a [routerLink]="['Heroes']">Heroes</a>
<router-outlet></router-outlet>
`,
// #enddocregion template
// #docregion directives-and-providers
directives: [ROUTER_DIRECTIVES],
providers: [
ROUTER_PROVIDERS,
HeroService
]
// #enddocregion directives-and-providers
})
// #docregion route-config
@RouteConfig([
{
path: '/heroes',
name: 'Heroes',
component: HeroesComponent
}
])
// #enddocregion route-config
export class AppComponent {
title = 'Tour of Heroes';
}
// #enddocregion