1
export class HomePage {
public news:Object;
constructor(public navCtrl: NavController,public httpdata:HttpdataproviderProvider) {
this.news = {};
this.getAllNews();
}
getAllNews(){
let url = 'some url';
this.httpdata.httpPost(url,someData) //some custom provider
.then(function(data){
console.log(this.news);
this.news = data;
})
}
}
为什么我不能访问新闻对象或将数据分配给新闻。它显示“无法读取属性‘离子2无法读取未定义的属性'新闻'
你的回调应该是箭头功能.. –