- Forums
- ionic
- Axample Of An Angular Ionic 2 Service Http.get In Typescript
this is a working example of a typescript file for using http.get data from json in angular and ionic 2 [4673], Last Updated: Mon Jun 24, 2024
Angular2
Mon Mar 27, 2017
0 Comments
415 Visits
here i have a good working example of a typescript file i created which fetches data from a json file using http.get()
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class QuestionsProvider {
data:any;
url:string='https://localhost/wallpaperama/quiz/post/WebuneQuiz.php?a=quizInfo&QuizId=65&noLang=0';
constructor(public http: Http) {
}
load() {
return new Promise(resolve => {
this.http.get(this.url)
.map(res => res.json())
.subscribe(data => {
this.data = data;
resolve(this.data);
});
});
}
}