我有這樣的JSON離子2如何綁定JSON到HTML頁面組件
{
"_index": "search_posts", "_type": "posts", "_id": "12345",
"_score": 0,
"_source": {
"alias_id": 0,
"user_id": 1,
"name": "demo",
"email": "[email protected]",
}
}
我得到的JSON這樣在我page.ts:
this.userDetails = this.navParams.get('params');
當我嘗試做一些像這在page.html中得到它拋出數據中的錯誤
<p id=userName>{{userDetails._source.name}}</p>
TypeError: Cannot read property '_source' of undefined
當我試圖訪問userDetails._source,其中_source指向我的json時,會導致錯誤。 – noor