app-service.ts
import { Injectable } from ‘@angular/core’;
import { Http } from ‘@angular/http’;
import ‘rxjs/add/operator/map’;
@Injectable()
export class AppServiceProvider {
baseUrl;
constructor(public http: Http) {
this.http=http;
this.baseUrl = ‘https://liverates.online/urbanpark/rates?filter={“provider”:“AED”}’;
console.log(‘Currency AppServiceProvider Provider’);
}
getPost(){
return this.http.get(this.baseUrl)
.map(res => res.json());
}
}
home.ts
import { AppServiceProvider } from ‘…/…/providers/app-service/app-service’;
import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {
items;
constructor(public appServiceProvider: AppServiceProvider,public navCtrl: NavController) {
}
ngOnInit(){
this.getPost();
}
getPost(){
this.appServiceProvider.getPost().subscribe(response =>{
console.log(JSON.stringify(response));
this.items = response;
})
}
ionViewDidLoad() {
console.log(‘ionViewDidLoad HomePage’);
}
}
home.html
CurrencyWhen im Trying to Parse Json into Html it shows "TypeError: Cannot read property ‘rates’ of undefined"
I need to get the USD and INR bind to html?