Angularjs 如何在Ionic2中获取数组Json
我想得到translatedText值。但是在console.log中保持show未定义。wAngularjs 如何在Ionic2中获取数组Json,angularjs,json,ionic-framework,Angularjs,Json,Ionic Framework,我想得到translatedText值。但是在console.log中保持show未定义。w this.getPosts('Hello', 'ja'); getPosts(text, category) { this.translateService.getPosts(text, category).subscribe(response => { console.log(response.data.translations.translateText); this.i
this.getPosts('Hello', 'ja');
getPosts(text, category) {
this.translateService.getPosts(text, category).subscribe(response => {
console.log(response.data.translations.translateText);
this.items = response.data.translations;
console.log(items.translateText)
}
这里是Json格式
{
"data": {
"translations": [
{
"translatedText": "Hallo Welt",
"detectedSourceLanguage": "en"
}
]
}
}
您是否有任何错误?我们不知道这个.translateService.getPosts()的作用。为什么不打印
response
(或者用调试器检查它),看看它实际上包含什么呢;应该是this.items=response.data.translations[0];我只是想从items.translation.translatedText中获取数据。但是当我使用console.log(this.items.translations.translatedText)时,它会显示未定义的。。。。。