| 
									
										
											  
											
												docs(toh-6): refactoring of 'add, edit, delete heroes' (#2170)
* docs(toh-6/dart): refactoring of 'add, edit, delete heroes'
Refactoring of "add, edit, delete heroes" section of toh-6 from one big
bottom-up step into small independent feature slices, where the user
achieves a "milesone" (i.e., can run the full app) after each feature
section. The section rewrite is shorter and offers a better UX.
Other simplifications:
- Error handling is consistent: in the hero service we log to the
console, everwhere else we just let errors bubble up.
- Hero service methods renamed based on function (create, update)
rather then lower-level implementation (post, put).
- @Output properties have been eliminated (since they weren't
explained).
E2E tests now pass on both the TS and Dart sides.
* docs(toh-6/ts): refactoring of 'add, edit, delete heroes'
Refactoring of "add, edit, delete heroes" section of toh-6 from one big
bottom-up step into small independent feature slices, where the user
achieves a "milesone" (i.e., can run the full app) after each feature
section. The section rewrite is shorter and offers a better UX.
Other simplifications:
- Error handling is consistent: in the hero service we log to the
console, everwhere else we just let errors bubble up.
- Hero service methods renamed based on function (create, update)
rather then lower-level implementation (post, put).
- @Output properties have been eliminated (since they weren't
explained).
E2E tests now pass on both the TS and Dart sides.
Post-Dart-review updates included.
* docs(toh-6): ward tweaks
											
										 
											2016-08-26 14:57:45 -07:00
										 |  |  | // #docregion
 | 
					
						
							| 
									
										
										
										
											2016-11-22 20:07:16 +08:00
										 |  |  | import 'rxjs/add/operator/switchMap'; | 
					
						
							| 
									
										
										
										
											2016-09-25 20:56:12 -05:00
										 |  |  | import { Component, OnInit }      from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | import { ActivatedRoute, Params } from '@angular/router'; | 
					
						
							| 
									
										
										
										
											2016-09-25 20:56:12 -05:00
										 |  |  | import { Location }               from '@angular/common'; | 
					
						
							| 
									
										
										
										
											2016-04-09 00:18:37 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | import { Hero }        from './hero'; | 
					
						
							|  |  |  | import { HeroService } from './hero.service'; | 
					
						
							| 
									
										
										
										
											2016-05-23 10:02:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-09 00:18:37 -04:00
										 |  |  | @Component({ | 
					
						
							| 
									
										
										
										
											2016-09-25 18:51:54 -07:00
										 |  |  |   moduleId: module.id, | 
					
						
							| 
									
										
										
										
											2016-04-09 00:18:37 -04:00
										 |  |  |   selector: 'my-hero-detail', | 
					
						
							| 
									
										
										
										
											2016-09-25 18:51:54 -07:00
										 |  |  |   templateUrl: 'hero-detail.component.html', | 
					
						
							|  |  |  |   styleUrls: [ 'hero-detail.component.css' ] | 
					
						
							| 
									
										
										
										
											2016-04-09 00:18:37 -04:00
										 |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | export class HeroDetailComponent implements OnInit { | 
					
						
							| 
									
										
											  
											
												docs(toh-6): refactoring of 'add, edit, delete heroes' (#2170)
* docs(toh-6/dart): refactoring of 'add, edit, delete heroes'
Refactoring of "add, edit, delete heroes" section of toh-6 from one big
bottom-up step into small independent feature slices, where the user
achieves a "milesone" (i.e., can run the full app) after each feature
section. The section rewrite is shorter and offers a better UX.
Other simplifications:
- Error handling is consistent: in the hero service we log to the
console, everwhere else we just let errors bubble up.
- Hero service methods renamed based on function (create, update)
rather then lower-level implementation (post, put).
- @Output properties have been eliminated (since they weren't
explained).
E2E tests now pass on both the TS and Dart sides.
* docs(toh-6/ts): refactoring of 'add, edit, delete heroes'
Refactoring of "add, edit, delete heroes" section of toh-6 from one big
bottom-up step into small independent feature slices, where the user
achieves a "milesone" (i.e., can run the full app) after each feature
section. The section rewrite is shorter and offers a better UX.
Other simplifications:
- Error handling is consistent: in the hero service we log to the
console, everwhere else we just let errors bubble up.
- Hero service methods renamed based on function (create, update)
rather then lower-level implementation (post, put).
- @Output properties have been eliminated (since they weren't
explained).
E2E tests now pass on both the TS and Dart sides.
Post-Dart-review updates included.
* docs(toh-6): ward tweaks
											
										 
											2016-08-26 14:57:45 -07:00
										 |  |  |   hero: Hero; | 
					
						
							| 
									
										
										
										
											2016-04-09 00:18:37 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   constructor( | 
					
						
							| 
									
										
										
										
											2016-05-23 10:02:17 +02:00
										 |  |  |     private heroService: HeroService, | 
					
						
							| 
									
										
										
										
											2016-09-25 20:56:12 -05:00
										 |  |  |     private route: ActivatedRoute, | 
					
						
							|  |  |  |     private location: Location | 
					
						
							|  |  |  |   ) {} | 
					
						
							| 
									
										
										
										
											2016-04-09 00:18:37 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-27 15:00:59 +02:00
										 |  |  |   ngOnInit(): void { | 
					
						
							| 
									
										
										
										
											2016-11-22 20:07:16 +08:00
										 |  |  |     this.route.params | 
					
						
							|  |  |  |       .switchMap((params: Params) => this.heroService.getHero(+params['id'])) | 
					
						
							|  |  |  |       .subscribe(hero => this.hero = hero); | 
					
						
							| 
									
										
										
										
											2016-04-09 00:18:37 -04:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-06-26 12:13:44 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-09 00:18:37 -04:00
										 |  |  |   // #docregion save
 | 
					
						
							| 
									
										
										
										
											2016-07-27 15:00:59 +02:00
										 |  |  |   save(): void { | 
					
						
							| 
									
										
											  
											
												docs(toh-6): refactoring of 'add, edit, delete heroes' (#2170)
* docs(toh-6/dart): refactoring of 'add, edit, delete heroes'
Refactoring of "add, edit, delete heroes" section of toh-6 from one big
bottom-up step into small independent feature slices, where the user
achieves a "milesone" (i.e., can run the full app) after each feature
section. The section rewrite is shorter and offers a better UX.
Other simplifications:
- Error handling is consistent: in the hero service we log to the
console, everwhere else we just let errors bubble up.
- Hero service methods renamed based on function (create, update)
rather then lower-level implementation (post, put).
- @Output properties have been eliminated (since they weren't
explained).
E2E tests now pass on both the TS and Dart sides.
* docs(toh-6/ts): refactoring of 'add, edit, delete heroes'
Refactoring of "add, edit, delete heroes" section of toh-6 from one big
bottom-up step into small independent feature slices, where the user
achieves a "milesone" (i.e., can run the full app) after each feature
section. The section rewrite is shorter and offers a better UX.
Other simplifications:
- Error handling is consistent: in the hero service we log to the
console, everwhere else we just let errors bubble up.
- Hero service methods renamed based on function (create, update)
rather then lower-level implementation (post, put).
- @Output properties have been eliminated (since they weren't
explained).
E2E tests now pass on both the TS and Dart sides.
Post-Dart-review updates included.
* docs(toh-6): ward tweaks
											
										 
											2016-08-26 14:57:45 -07:00
										 |  |  |     this.heroService.update(this.hero) | 
					
						
							| 
									
										
										
										
											2016-09-25 20:56:12 -05:00
										 |  |  |       .then(() => this.goBack()); | 
					
						
							| 
									
										
										
										
											2016-04-09 00:18:37 -04:00
										 |  |  |   } | 
					
						
							|  |  |  |   // #enddocregion save
 | 
					
						
							| 
									
										
											  
											
												docs(toh-6): refactoring of 'add, edit, delete heroes' (#2170)
* docs(toh-6/dart): refactoring of 'add, edit, delete heroes'
Refactoring of "add, edit, delete heroes" section of toh-6 from one big
bottom-up step into small independent feature slices, where the user
achieves a "milesone" (i.e., can run the full app) after each feature
section. The section rewrite is shorter and offers a better UX.
Other simplifications:
- Error handling is consistent: in the hero service we log to the
console, everwhere else we just let errors bubble up.
- Hero service methods renamed based on function (create, update)
rather then lower-level implementation (post, put).
- @Output properties have been eliminated (since they weren't
explained).
E2E tests now pass on both the TS and Dart sides.
* docs(toh-6/ts): refactoring of 'add, edit, delete heroes'
Refactoring of "add, edit, delete heroes" section of toh-6 from one big
bottom-up step into small independent feature slices, where the user
achieves a "milesone" (i.e., can run the full app) after each feature
section. The section rewrite is shorter and offers a better UX.
Other simplifications:
- Error handling is consistent: in the hero service we log to the
console, everwhere else we just let errors bubble up.
- Hero service methods renamed based on function (create, update)
rather then lower-level implementation (post, put).
- @Output properties have been eliminated (since they weren't
explained).
E2E tests now pass on both the TS and Dart sides.
Post-Dart-review updates included.
* docs(toh-6): ward tweaks
											
										 
											2016-08-26 14:57:45 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   goBack(): void { | 
					
						
							| 
									
										
										
										
											2016-09-25 20:56:12 -05:00
										 |  |  |     this.location.back(); | 
					
						
							| 
									
										
										
										
											2016-04-09 00:18:37 -04:00
										 |  |  |   } | 
					
						
							|  |  |  | } |