0
我使用AngularJS显示带有来自JSON的引用ID的数据。但是JSON结构稍微改变了,所以引用ID没有正确地得到。使用AngularJS显示来自JSON的refference id的数据
上一页JSON:
{
"tid": "2440",
"name": "Alfredo's Pizzeria",
"field_location_category": [
"Food and Dining"
]
},
{
"tid": "2441",
"name": "Allegro Dining Room",
"field_location_category": [
"Food and Dining"
]
},
{
"tid": "2443",
"name": "Art Gallery",
"field_location_category": [
"Gifts & Memories"
]
},
{
"tid": "2435",
"name": "Bellini's",
"field_location_category": [
"Entertainment/Bars"
]
},
{
"tid": "2498",
"name": "Bullseye",
"field_location_category": [
"Pools, Sports & Spa"
]
}
当前JSON:
{
"count": 70,
"language": "en",
"0": {
"id": "2420",
"title": "Medical Center",
"description": "The medical staff on-board are available for consultation; hours are posted in the Princess Patter. Please contact the Medical Center should you suffer from motion sickness and require a remedy. Professional services as well as medications are provided at reasonable costs. For medical emergencies, please dial 911. Your stateroom stateroom steward can provide you with the necessary safe waste receptacle if you have a medical condition that requires the use of sharps or needles.",
"time": "8:00am-10:00am & 4:30pm-6:30pm",
"manager": null,
"cover_charge": "",
},
"1": {
"id": "7840",
"title": "Conference Room - Deck 5 Portside",
"description": "Located on Deck 5 on both portside and starboard sides, the conference rooms onboard Regal Princess can be reserved for group meetings. Please enquire for details at the Passenger Services Desk.",
"time": null,
"manager": null,
"cover_charge": null,
},
"2": {
"id": "2426",
"title": "Conference Room - Deck 5 Starboard",
"description": "Located on Deck 5 on both portside and starboard sides, the conference rooms onboard Regal Princess can be reserved for group meetings. Please enquire for details at the Passenger Services Desk.",
"time": null,
"manager": null,
"cover_charge": "",
}
}
,且控制器
var detailResult = $filter('filter')($scope.locationDetail, {id:path})[0];
这里$scope.locationDetail
是我的JSON数据和path
是对应的ID从得到URL。
我检查了$scope.locationDetail
和path
,两者都正确。我认为问题是从最后一节{id:path})[0];
。 id
参考不正确。
@vimal是否适合你? – 2015-02-18 18:38:30