我有2个http获取JSON格式数据的第一个:
category:2
city_code:"C!000871"
country:"TH"
hotel_code:"H!0532874"
name:"Chaulty Towers Guest House"
然后依赖于hotel_code
我发送了另一个$http.get
请求,新数据如下:
address:"149/41 Moo 4, Maret, Lamai 84310 Koh Samui Moo 4, Maret, Lamai"
category:"2"
city_code:"C!000871"
code:"H!0532874"
hotel_code
与code
相同,我可以在与address
hotel_code
视图中显示
PS:
在我看来,我对第一组数据ng-repeat="data in data | limitTo: 10"
。
答案 0 :(得分:2)
您可以尝试:添加评论:
// Iterate 1st Array
for (var i = 0; i < HouseNames.length; i++) {
// Iterate 2nd Array
for (var k = 0; k < HotelDetails.length; k++) {
// Check for Hotel code
if (HouseNames[i].hotel_code == HotelDetails[k].code) {
// If hotel code matches add it to 1st array
HouseNames[i].hotelDetails = HotelDetails[k];
}
}
}
console.log(HouseNames);
答案 1 :(得分:1)
您可以创建一些函数来从控制器获取第二个数据集,然后使用相同数组的ng-repeat制作地图并显示数据。
$scope.data = [your data here].map(function(item){
get_2nd_json_resp_by_hotel_code(item.hotel_code).then(
function(res){
$scope.data = angular.extend($scope.data ,res);
}
);
});