Skip to content

Commit 860e88c

Browse files
gjungbmhevery
authored andcommitted
docs(Http): add type annotations to clarify API
IMHO this tiny example is easier to read when some type annotations are added and the parameter names are more concise. Closes angular#4614
1 parent ebd15a7 commit 860e88c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

modules/playground/src/http/http_comp.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, View, NgFor} from 'angular2/angular2';
2-
import {Http} from 'angular2/http';
2+
import {Http, Response} from 'angular2/http';
33

44
@Component({selector: 'http-app'})
55
@View({
@@ -14,8 +14,10 @@ import {Http} from 'angular2/http';
1414
`
1515
})
1616
export class HttpCmp {
17-
people: Object;
17+
people: Object[];
1818
constructor(http: Http) {
19-
http.get('./people.json').map(res => res.json()).subscribe(res => this.people = res);
19+
http.get('./people.json')
20+
.map((res: Response) => res.json())
21+
.subscribe((people: Array<Object>) => this.people = people);
2022
}
2123
}

0 commit comments

Comments
 (0)