| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  | /* tslint:disable:no-unused-variable */ | 
					
						
							| 
									
										
										
										
											2015-12-14 18:19:17 -08:00
										 |  |  | // #docplaster
 | 
					
						
							| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  | import { Component, OnInit } from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { Router, ROUTER_DIRECTIVES, Routes } from '@angular/router'; | 
					
						
							| 
									
										
										
										
											2015-12-14 18:19:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  | import { CrisisCenterComponent } from './crisis-center/crisis-center.component.1'; | 
					
						
							|  |  |  | import { HeroDetailComponent }   from './heroes/hero-detail.component.1'; | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { HeroListComponent }     from './heroes/hero-list.component.1'; | 
					
						
							| 
									
										
										
										
											2015-12-14 18:19:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  | import { DialogService }         from './dialog.service'; | 
					
						
							|  |  |  | import { HeroService }           from './heroes/hero.service'; | 
					
						
							| 
									
										
										
										
											2015-12-14 18:19:17 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'my-app', | 
					
						
							|  |  |  | // #enddocregion
 | 
					
						
							|  |  |  |   /* Typical link | 
					
						
							| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  |    // #docregion h-anchor
 | 
					
						
							|  |  |  |    <a [routerLink]="['/heroes']">Heroes</a> | 
					
						
							|  |  |  |    // #enddocregion h-anchor
 | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-12-14 18:19:17 -08:00
										 |  |  |   /* Incomplete Crisis Center link when CC lacks a default | 
					
						
							| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  |    // #docregion cc-anchor-fail
 | 
					
						
							|  |  |  |    // The link now fails with a "non-terminal link" error
 | 
					
						
							|  |  |  |    // #docregion cc-anchor-w-default
 | 
					
						
							|  |  |  |    <a [routerLink]="['/crisis-center']">Crisis Center</a> | 
					
						
							|  |  |  |    // #enddocregion cc-anchor-w-default
 | 
					
						
							|  |  |  |    // #enddocregion cc-anchor-fail
 | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-12-14 18:19:17 -08:00
										 |  |  |   /* Crisis Center link when CC lacks a default | 
					
						
							| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  |    // #docregion cc-anchor-no-default
 | 
					
						
							|  |  |  |    <a [routerLink]="['/crisis-center/']">Crisis Center</a> | 
					
						
							|  |  |  |    // #enddocregion cc-anchor-no-default
 | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-12-14 18:19:17 -08:00
										 |  |  |   /* Crisis Center Detail link | 
					
						
							| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  |    // #docregion Dragon-anchor
 | 
					
						
							|  |  |  |    <a [routerLink]="['/crisis-center/1']">Dragon Crisis</a> | 
					
						
							|  |  |  |    // #enddocregion Dragon-anchor
 | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-12-14 18:19:17 -08:00
										 |  |  | // #docregion template
 | 
					
						
							|  |  |  |   template: `
 | 
					
						
							|  |  |  |     <h1 class="title">Component Router</h1> | 
					
						
							| 
									
										
										
										
											2015-12-31 16:55:53 -08:00
										 |  |  |     <nav> | 
					
						
							| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  |       <a [routerLink]="['/crisis-center']">Crisis Center</a> | 
					
						
							|  |  |  |       <a [routerLink]="['/crisis-center', 1]">Dragon Crisis</a> | 
					
						
							|  |  |  |       <a [routerLink]="['/crisis-center', 2]">Shark Crisis</a> | 
					
						
							| 
									
										
										
										
											2015-12-31 16:55:53 -08:00
										 |  |  |     </nav> | 
					
						
							| 
									
										
										
										
											2015-12-14 18:19:17 -08:00
										 |  |  |     <router-outlet></router-outlet> | 
					
						
							|  |  |  |   `,
 | 
					
						
							|  |  |  | // #enddocregion template
 | 
					
						
							| 
									
										
										
										
											2015-12-31 16:55:53 -08:00
										 |  |  |   providers:  [DialogService, HeroService], | 
					
						
							| 
									
										
										
										
											2015-12-14 18:19:17 -08:00
										 |  |  |   directives: [ROUTER_DIRECTIVES] | 
					
						
							|  |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  | @Routes([ | 
					
						
							|  |  |  |   {path: '/crisis-center', component: CrisisCenterComponent}, | 
					
						
							|  |  |  |   {path: '*',        component: CrisisCenterComponent} | 
					
						
							| 
									
										
										
										
											2015-12-14 18:19:17 -08:00
										 |  |  | ]) | 
					
						
							| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  | export class AppComponent implements OnInit { | 
					
						
							|  |  |  |   constructor(private router: Router) {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ngOnInit() { | 
					
						
							|  |  |  |     this.router.navigate(['/crisis-center']); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |