@@ -12,8 +12,6 @@ block includes
12
12
- var _promise = _Promise .toLowerCase ()
13
13
14
14
:marked
15
- # Getting and Saving Data
16
-
17
15
Our stakeholders appreciate our progress.
18
16
Now they want to get the hero data from a server, let users add, edit, and delete heroes,
19
17
and save these changes back to the server.
@@ -155,7 +153,7 @@ block get-heroes-details
155
153
*Observables* are a powerful way to manage asynchronous data flows.
156
154
We'll learn about [Observables](#observables) later in this chapter.
157
155
158
- For *now* we get back on familiar ground by immediately by
156
+ For *now* we get back on familiar ground by immediately
159
157
converting that `Observable` to a `Promise` using the `toPromise` operator.
160
158
161
159
+ makeExcerpt('app/hero.service.ts' , 'to-promise' , '' )
@@ -219,7 +217,7 @@ block get-heroes-details
219
217
Although we made significant *internal* changes to `getHeroes()`, the public signature did not change.
220
218
We still return a !{_Promise}. We won't have to update any of the components that call `getHeroes()`.
221
219
222
- Our stakeholders are thrilled with the added flexibility from the API integration.
220
+ Our stakeholders are thrilled with the added flexibility from the API integration.
223
221
Now they want the ability to create and delete heroes.
224
222
225
223
Let's see first what happens when we try to update a hero's details.
@@ -229,7 +227,7 @@ block get-heroes-details
229
227
## Update hero details
230
228
231
229
We can edit a hero's name already in the hero detail view. Go ahead and try
232
- it. As we type, the hero name is updated in the view heading.
230
+ it. As we type, the hero name is updated in the view heading.
233
231
But when we hit the `Back` button, the changes are lost!
234
232
235
233
.l-sub-section
@@ -294,7 +292,11 @@ block get-heroes-details
294
292
When the given name is non-blank, the handler delegates creation of the
295
293
named hero to the hero service, and then adds the new hero to our !{_array}.
296
294
297
- Go ahead, refresh the browser and create some new heroes!
295
+ Finally, we implement the `create` method in the `HeroService` class.
296
+ + makeExcerpt('app/hero.service.ts' , 'create' )
297
+
298
+ :marked
299
+ Refresh the browser and create some new heroes!
298
300
299
301
.l-main-section
300
302
:marked
@@ -344,6 +346,7 @@ block get-heroes-details
344
346
:marked
345
347
Refresh the browser and try the new delete functionality.
346
348
349
+ #observables
347
350
:marked
348
351
## !{_Observable}s
349
352
@@ -510,7 +513,7 @@ block observable-transformers
510
513
- var _declarations = _docsFor == ' dart' ? ' directives' : ' declarations'
511
514
- var declFile = _docsFor == ' dart' ? ' app/dashboard.component.ts' : ' app/app.module.ts'
512
515
:marked
513
- Finally, we import `HeroSearchComponent` from
516
+ Finally, we import `HeroSearchComponent` from
514
517
<span ngio-ex>hero-search.component.ts</span>
515
518
and add it to the `!{_declarations}` !{_array}:
516
519
@@ -532,7 +535,7 @@ figure.image-display
532
535
533
536
block filetree
534
537
.filetree
535
- .file angular2 -tour-of-heroes
538
+ .file angular -tour-of-heroes
536
539
.children
537
540
.file app
538
541
.children
@@ -577,7 +580,7 @@ block filetree
577
580
- We configured an in-memory web API.
578
581
- We learned how to use !{_Observable}s.
579
582
580
- Here are the files we added or changed in this chapter.
583
+ Here are the files we _added or changed_ in this chapter.
581
584
582
585
block file-summary
583
586
+ makeTabs(
0 commit comments