Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 81096fd

Browse files
docs(HTTP Client): edits up to The HeroListComponent class
1 parent fdc1b04 commit 81096fd

File tree

3 files changed

+48
-47
lines changed

3 files changed

+48
-47
lines changed

public/docs/_examples/server-communication/ts/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { Component } from '@angular/core';
44

55
// #docregion import-rxjs
6-
// Add the RxJS Observable operators we need in this app.
6+
// Add the RxJS Observable operators.
77
import './rxjs-operators';
88
// #enddocregion import-rxjs
99

public/docs/ts/latest/guide/_data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108

109109
"server-communication": {
110110
"title": "HTTP Client",
111-
"intro": "Talk to a remote server with an HTTP Client."
111+
"intro": "Use an HTTP Client to talk to a remote server."
112112
},
113113

114114
"lifecycle-hooks": {

public/docs/ts/latest/guide/server-communication.jade

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,117 +9,118 @@ block includes
99
.l-sub-section
1010
:marked
1111
The [`WebSocket`](https://tools.ietf.org/html/rfc6455) protocol is another important communication technology;
12-
we won't cover it in this chapter.
12+
it isn't covered in this page.
1313
:marked
1414
Modern browsers support two HTTP-based APIs:
1515
[XMLHttpRequest (XHR)](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) and
1616
[JSONP](https://en.wikipedia.org/wiki/JSONP). A few browsers also support
1717
[Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
1818

19-
The !{_Angular_http_library} simplifies application programming of the **XHR** and **JSONP** APIs
20-
as we'll learn in this chapter covering:
19+
The !{_Angular_http_library} simplifies application programming with the **XHR** and **JSONP** APIs.
20+
This page covers:
2121

22-
- [HTTP client sample overview](#http-client)
22+
- [The Tour of Heroes *HTTP* client demo](#http-client)
2323
- [Fetch data with http.get](#fetch-data)
24-
<li if-docs="ts"> [RxJS Observable of HTTP Responses](#rxjs)</li>
25-
<li if-docs="ts"> [Enabling RxJS Operators](#enable-rxjs-operators)</li>
26-
- [Extract JSON data](#extract-data)
27-
- [Error handling](#error-handling)
24+
<li if-docs="ts"> [RxJS library](#rxjs)</li>
25+
<li if-docs="ts"> [Enable RxJS operators](#enable-rxjs-operators)</li>
26+
- [Process the response object](#extract-data)
27+
- [Always handle errors](#error-handling)
2828
- [Send data to the server](#update)
29-
<li if-docs="ts"> [Promises instead of observables](#promises)</li>
29+
<li if-docs="ts"> [Fall back to promises](#promises)</li>
3030
- [Cross-origin requests: Wikipedia example](#cors)
3131
<ul if-docs="ts">
32-
<li> [Set query string parameters](#search-parameters)</li>
33-
<li> [Debounce search term input](#more-observables)</li>
32+
<li> [Search parameters](#search-parameters)</li>
33+
<li> [More fun with observables](#more-observables)</li>
3434
</ul>
35-
- [Appendix: the in-memory web api service](#in-mem-web-api)
35+
- [Appendix: Tour of Heroes in-memory server](#in-mem-web-api)
3636

37-
We illustrate these topics with code that you can <live-example>run live</live-example>.
37+
These topics are illustrated with code that you can <live-example>run live</live-example>.
3838

3939
.l-main-section
4040
:marked
4141
# Demos
4242

43-
This chapter describes server communication with the help of the following demos
43+
This page describes server communication with the help of the following demos:
4444

4545
block demos-list
4646
:marked
47-
- [HTTP client: Tour of Heroes with Observables](#http-client)
48-
- [HTTP client: Tour of Heroes with !{_Promise}s](#promises)
49-
- [JSONP client: Wikipedia to fetch data from a service that does not support CORS](#cors)
50-
- [JSONP client: Wikipedia using observable operators to reduce server calls](#more-observables)
47+
- [The Tour of Heroes *HTTP* client demo](#http-client)
48+
- [Fall back to !{_Promise}s](#promises)
49+
- [Cross-origin requests: Wikipedia example](#cors)
50+
- [More fun with observables](#more-observables)
5151

5252
:marked
53-
These demos are orchestrated by the root `AppComponent`
53+
The root `AppComponent` orchestrates these demos.
5454
+makeExample('server-communication/ts/app/app.component.ts', null, 'app/app.component.ts')
5555

5656
+ifDocsFor('ts')
5757
:marked
58-
There is nothing remarkable here _except_ for the import of RxJS operators.
58+
There is nothing remarkable here _except_ for the import of RxJS operators, which is
59+
described [later](#rxjs).
5960
+makeExample('server-communication/ts/app/app.component.ts', 'import-rxjs')(format='.')
60-
:marked
61-
We'll talk about that [below](#rxjs) when we're ready to explore observables.
6261
:marked
63-
First, we have to configure our application to use server communication facilities.
62+
First, configure the application to use server communication facilities.
6463

6564
.l-main-section#http-providers
6665
:marked
67-
# Providing HTTP Services
66+
# Providing HTTP services
6867

69-
We use the !{_Angular_Http} client to communicate with a server using a familiar HTTP request/response protocol.
68+
The !{_Angular_Http} client communicates with the server using a familiar HTTP request/response protocol.
7069
The `!{_Http}` client is one of a family of services in the !{_Angular_http_library}.
7170

7271
+ifDocsFor('ts')
7372
.l-sub-section
7473
:marked
75-
SystemJS knows how to load services from the !{_Angular_http_library} when we import from the `@angular/http` module
76-
because we registered that module name in the `system.config` file.
74+
When you import from the `@angular/http` module, SystemJS knows how to load services from
75+
the !{_Angular_http_library}
76+
because you registered that module name in the `system.config` file.
7777

7878
:marked
79-
Before we can use the `!{_Http}` client , we'll have to register it as a service provider with the Dependency Injection system.
79+
Before you can use the `!{_Http}` client, you need to register it as a service provider with the dependency injection system.
8080

8181
.l-sub-section
8282
:marked
83-
Learn about providers in the [Dependency Injection](dependency-injection.html) chapter.
83+
Read about providers in the [Dependency Injection](dependency-injection.html) page.
8484

8585
:marked
86-
In this demo, we register providers by importing other NgModules to our root NgModule.
86+
Register providers by importing other NgModules to the root NgModule.
8787

8888
+makeExample('server-communication/ts/app/app.module.1.ts', null, 'app/app.module.ts (v1)')(format='.')
8989

9090
block http-providers
9191
:marked
92-
We begin by importing the symbols we need, most of them familiar by now.
92+
Begin by importing the necessary symbols; most of them should be familiar by now.
9393
The newcomers are the `HttpModule` and the `JsonpModule` from the !{_Angular_http_library}.
9494

95-
We add these modules to the application by passing them to the `imports` array in our root NgModule.
95+
To add these modules to the application, pass them to the `imports` array in the root NgModule.
9696
.l-sub-section
9797
:marked
98-
We need the HttpModule to make HTTP calls.
99-
We don't need the JsonpModule for plain HTTP.
100-
We will demonstrate JSONP support later in this chapter.
101-
We're loading its module now to save time.
98+
You need the HttpModule to make HTTP calls.
99+
Though the JsonpModule isn't necessary for plain HTTP,
100+
there is a JSONP demo later in this page.
101+
Loading its module now saves time.
102102
.l-main-section#http-client
103103
:marked
104-
# The Tour of Heroes _HTTP_ Client Demo
104+
# The Tour of Heroes _HTTP_ client demo
105105

106-
Our first demo is a mini-version of the [tutorial](../tutorial)'s "Tour of Heroes" (ToH) application.
107-
This version gets some heroes from the server, displays them in a list, lets us add new heroes, and saves them to the server.
108-
We use the !{_Angular_Http} client to communicate via `XMLHttpRequest (XHR)`.
106+
The first demo is a mini-version of the [tutorial](../tutorial)'s "Tour of Heroes" (ToH) application.
107+
This version gets some heroes from the server, displays them in a list, lets you add new heroes, and saves them to the server.
108+
You use the !{_Angular_Http} client to communicate via `XMLHttpRequest (XHR)`.
109109

110-
It works like this.
110+
It works like this:
111111
figure.image-display
112112
img(src='/resources/images/devguide/server-communication/http-toh.gif' alt="ToH mini app" width="250")
113113
:marked
114114
This demo has a single component, the `HeroListComponent`. Here's its template:
115115
+makeExample('server-communication/ts/app/toh/hero-list.component.html', null, 'app/toh/hero-list.component.html (template)')
116116
:marked
117117
It presents the list of heroes with an `ngFor`.
118-
Below the list is an input box and an *Add Hero* button where we can enter the names of new heroes
118+
Below the list is an input box and an *Add Hero* button where you can enter the names of new heroes
119119
and add them to the database.
120-
We use a [template reference variable](template-syntax.html#ref-vars), `newHeroName`, to access the
120+
A [template reference variable](template-syntax.html#ref-vars), `newHeroName`, discussed in the
121+
[Template Syntax](template-syntax.html) page, accesses the
121122
value of the input box in the `(click)` event binding.
122-
When the user clicks the button, we pass that value to the component's `addHero` method and then
123+
When the user clicks the button, you pass that value to the component's `addHero` method and then
123124
clear it to make it ready for a new hero name.
124125

125126
Below the button is an area for an error message.
@@ -167,7 +168,7 @@ block getheroes-and-addhero
167168
a#HeroService
168169
.l-main-section#fetch-data
169170
:marked
170-
## Fetch data with the **HeroService**
171+
## Fetch data with http.get
171172

172173
In many of our previous samples we faked the interaction with the server by
173174
returning mock heroes in a service like this one:

0 commit comments

Comments
 (0)