我想从返回的JSON请求中检索特殊数组元素。到目前为止,我可以得到整个饲料,但我正在努力如何将其限制到一个特定的元素。Ionic返回JSON数组中的特定数组项目
到目前为止,我在我的服务控制器中有这个;
getJsonData(){
return this.http.get('https://www.reddit.com/r/worldnews/.json').map(res => res.json());
}
在我的页面中,
getdata() {
this.HttpModule.getJsonData().subscribe(
result => {
this.News= result.data.children(1);
console.log("success:"+this.News);
},
err => {
console.error("Error : "+err);
},
() => {
console.log("getData completed");
}
);
}
应该children
由我试图children(1)
的猜测,但它没有工作
你尝试解析您的结果与'JSON反对.Parse'然后访问儿童[1]? –