<ion-list>
<ion-item *ngFor="let post of postList">
<p>{{post.d.category}}</p>
</ion-item>
</ion-list>
Here is home.ts:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { DetailPage } from '../detail/detail';
import { RemoteServiceProvider } from '../../providers/remote-service/remote-service';
@Component({
selector: 'page-home',
templateUrl: 'home.html',
})
export class HomePage {
postList: any = [];
tabBarElement: any;
splash = true;
constructor(public navCtrl: NavController, private remoteServiceprovider: RemoteServiceProvider) {
this.postList = this.getPosts();
}
}
Here is the remote-service.ts:
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
/*
Generated class for the RemoteServiceProvider provider.
See https://angular.io/docs/ts/latest/guide/dependency-injection.html
for more info on providers and Angular DI.
*/
@Injectable()
export class RemoteServiceProvider {
getPosts() {
return this.http.get("http://soko360.com/io/v1?opt=news&category=Local&format=json&r=0.18743093903875763")
.map(res => res.json());
}
constructor(public http: Http) {
console.log('Hello RemoteServiceProvider');
}
}
Also I can’t check what https://soko360.com/io/v1?opt=news&category=Local&format=json&r=0.18743093903875763 returns as I get an unauthorized error, but it doesn’t seem to be a list/array of things (referring to your first post, which is just 1 object).
I think you might get the compiler to help guide you towards solutions with problems like this if you start aggressively declaring property types and return values of methods, including never using any,