refactor: use new Http library in playground (#29355)

PR Close #29355
This commit is contained in:
Adam Plumer
2019-03-16 22:13:26 -05:00
committed by Andrew Kushnir
parent c99d379cc8
commit acfcf90528
7 changed files with 30 additions and 20 deletions

View File

@ -6,8 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/
import {HttpClient} from '@angular/common/http';
import {Component} from '@angular/core';
import {Jsonp} from '@angular/http';
interface Person {
name: string;
}
@Component({
selector: 'jsonp-app',
@ -15,14 +19,14 @@ import {Jsonp} from '@angular/http';
<h1>people</h1>
<ul class="people">
<li *ngFor="let person of people">
hello, {{person['name']}}
hello, {{person.name}}
</li>
</ul>
`
})
export class JsonpCmp {
people: Object;
constructor(jsonp: Jsonp) {
jsonp.get('./people.json?callback=JSONP_CALLBACK').subscribe(res => this.people = res.json());
people: Person[];
constructor(http: HttpClient) {
http.jsonp('./people.json', 'callback').subscribe(res => this.people = res);
}
}