2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2019-03-16 22:13:26 -05:00
|
|
|
import {HttpClient} from '@angular/common/http';
|
2016-04-28 17:50:03 -07:00
|
|
|
import {Component} from '@angular/core';
|
2019-03-16 22:13:26 -05:00
|
|
|
|
|
|
|
interface Person {
|
|
|
|
name: string;
|
|
|
|
}
|
2015-07-14 19:53:04 -05:00
|
|
|
|
2015-12-10 16:24:34 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'jsonp-app',
|
2015-07-14 19:53:04 -05:00
|
|
|
template: `
|
|
|
|
<h1>people</h1>
|
|
|
|
<ul class="people">
|
2016-04-25 19:52:24 -07:00
|
|
|
<li *ngFor="let person of people">
|
2019-03-16 22:13:26 -05:00
|
|
|
hello, {{person.name}}
|
2015-07-14 19:53:04 -05:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
export class JsonpCmp {
|
2019-03-16 22:13:26 -05:00
|
|
|
people: Person[];
|
|
|
|
constructor(http: HttpClient) {
|
|
|
|
http.jsonp('./people.json', 'callback').subscribe(res => this.people = res);
|
2015-07-14 19:53:04 -05:00
|
|
|
}
|
|
|
|
}
|