0
我试图从服务器获取数据,然后在Ionic页面中显示,到目前为止,我可以获取没有问题的数据并在控制台中检查。 但是,服务器如何返回给我?订阅后我如何在离子中填充角度变量?
所以我有这个功能的提供商
public LoadArticle(article_id:any){
let headers = new Headers();
let postData:any;
postData = {
task: 'GetArticle',
article_id: article_id
}
headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
return this.http.post(this.apiUrl, JSON.stringify(postData),{ headers: headers });
}
我这样称呼它在页面上我想显示
constructor(
public navCtrl: NavController,
public controller: WebservicesProvider
) {
}
this.controller.LoadArticle(1).subscribe(
data => {
let retorno: any;
retorno = data;
console.log(JSON.parse(retorno._body));
// this.navCtrl.setRoot(AbasPage);
// this.article_array = retorno._body.dados;
this.articlearray.id = retorno._body.dados.id;
this.articleLoaded = true;
},
error => {
console.log(error)
this.controller.endLoading();
},
() => {
this.controller.endLoading();
}
);
如果我写{{articlearray.id}}页面HTML文件我得到了一个错误
Cannot read property 'id' of undefined
什么即时做错了?