chore(http): update http example to include map operator

This commit is contained in:
Jeff Cross 2015-12-01 13:30:14 -08:00 committed by Jeremy Elbourn
parent 5514dc19d9
commit f76eea4f9b
1 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import {Component, View, NgFor} from 'angular2/angular2'; import {Component, View, NgFor} from 'angular2/angular2';
import {Http, Response} from 'angular2/http'; import {Http, Response} from 'angular2/http';
import 'rxjs/operators/map';
@Component({selector: 'http-app'}) @Component({selector: 'http-app'})
@View({ @View({
@ -16,6 +17,8 @@ import {Http, Response} from 'angular2/http';
export class HttpCmp { export class HttpCmp {
people: Object[]; people: Object[];
constructor(http: Http) { constructor(http: Http) {
http.get('./people.json').subscribe(res => { this.people = res.json(); }); http.get('./people.json')
.map((res: Response) => res.json())
.subscribe((people: Array<Object>) => this.people = people);
} }
} }