loadPeople(){
this.myService.load().then(data => {
this.people = data;
alert(this.people);
});
}
它提醒JSON爲:
{
"status": "true",
"statusCode": 200,
"response": [{
"user_id": "92",
"firstname": "joy",
"lastname": "Panchal",
"email": "[email protected]",
"password": "7Y7+K0vZIVWPDUQH++Iu+/+tMZ",
"user_type_id": "1"
}, {
"user_id": "89",
"firstname": "mark",
"lastname": "haris",
"email": "[email protected]",
"password": "4JICqnTkR8ysTI+nQQ+rpfAf7e",
"user_type_id": "1"
}]
}
現在我試圖通過
訪問 「迴應」loadPeople(){
this.myService.load().then(data => {
this.people = data.response;
alert(this.people);
});
}
但它警報爲「未定義」。
任何人都可以告訴我在哪裏失蹤?
應該完全正常工作。 http://jsfiddle.net/ADukg/10046/ – Matheno
是的,它應該,但不知道出了什麼問題。警報仍然說「未定義」 –
可能this.people尚未填充。 – Matheno