Hi, I am new to the framework and have been trying with failed attempts to parse some Json from a URL. I just want to be able to see if the parse is working with a json object in a console.log output. If anyone can point me in the right direction for how to accomplish this it would be greatly appreciated. Thanks!
Json url: http://app.toronto.ca/cc_sr_v1_app/data/edc_eventcal_APR?limit=500
home.ts
export class HomePage {
eventData: any;
loading: any;
//injecting HttpProvider with angular 2 dependancy in ctor + Loader
constructor(public navCtrl: NavController, private httpProvider:HttpProvider, public loadingCtrl: LoadingController) {
this.loading = this.loadingCtrl.create({
content: `
<ion-spinner ></ion-spinner>`
});
this.getdata();
}
getdata(){
this.httpProvider.getJsonData().subscribe(
result => {
this.eventData=result.calEvent.children;
console.log("it works...: " + this.eventData);
},
err =>{
console.error("Error : " +err);
},
() => {
console.log('getData completed');
}
);
}
}
providers https.ts
getJsonData(){
return this.http.get('http://app.toronto.ca/cc_sr_v1_app/data/edc_eventcal_APR?limit=500').map(res => res.json());
}
}
home.html
<ion-content padding>
<ion-list >
<ion-item text-wrap *ngFor="let item of eventData" >
<p >{{item.calEvent.orgType}}</p>
</ion-item>
</ion-list>
</ion-content>