// #docplaster // #docregion import { Component, OnInit } from '@angular/core'; import { Routes, Router, ROUTER_DIRECTIVES } from '@angular/router'; import { CrisisCenterComponent } from './crisis-center/crisis-center.component'; import { HeroListComponent } from './heroes/hero-list.component'; import { HeroDetailComponent } from './heroes/hero-detail.component'; import { DialogService } from './dialog.service'; import { HeroService } from './heroes/hero.service'; @Component({ selector: 'my-app', // #docregion template template: `

Component Router

`, // #enddocregion template providers: [DialogService, HeroService], directives: [ROUTER_DIRECTIVES] }) // #docregion routes @Routes([ {path: '/crisis-center', component: CrisisCenterComponent}, {path: '/heroes', component: HeroListComponent}, {path: '/hero/:id', component: HeroDetailComponent}, ]) // #enddocregion routes export class AppComponent implements OnInit { constructor(private router: Router) {} ngOnInit() { this.router.navigate(['/crisis-center']); } }