mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-24 14:58:36 +08:00
22 lines
577 B
JavaScript
22 lines
577 B
JavaScript
import {Injectable} from 'angular2/angular2';
|
|
import {Http} from 'angular2/http';
|
|
|
|
@Injectable()
|
|
export class <%= jsClassName %> {
|
|
constructor(http: Http) {
|
|
this.http = http;
|
|
this.data = null;
|
|
}
|
|
|
|
retrieveData() {
|
|
//Here, we're going to get a JSON data file, use the `map` call to parse json
|
|
// and finally subscribe to the observable and set our data
|
|
//to the value it provides once the http request is complete.
|
|
this.http.get('path/to/data.json')
|
|
.map(res => res.json())
|
|
.subscribe(data => {
|
|
this.data = data;
|
|
});
|
|
}
|
|
}
|