Я хочу отсортировать данные ответа по свойству цены, проблема в том, что есть элементы, которые определены как массив, и у каждого элемента есть цена, я хочу, чтобы весь список был отсортирован. Моя проблема сейчас связана с типом 2 (вложенный ng-repeat). В настоящее время тип 1 и 3 отображаются правильно, а затем тип 2 не сортируется.
HTML:
<div class="flex-container row-cont">
<div class="flex-container column prodlist">
<ul>
<li ng-repeat="x in response.data | orderBy:sortprice">
<div ng-if="x.type=='3'">
<div class="product flex-container row">
<div>{{x.price}}</div>
</div>
</div>
<div class="product flex-container row" ng if="x.type=='1'">
<div>{{x.fedex.price}}</div>
</div>
<div class="product flex-container row" ng-if="x.type=='2'" ng-repeat="obj in x.ups">
<div>{{obj.price}}</div>
</div>
</li>
javaScript:
$scope.sortprice = function (item) {
if (item.type == 1) {
return item.fedex.price;
}
if (item.type == 2) {
return ???;
}
if (item.type == 3) {
return item.price;
}
JSON:
({
"fedex": {
"creationDate": 1530110788904,
"description": "loloo",
"id": 1,
"name": "product 1",
"price": 10,
"thumbnailUrl": "http://placehold.it/150/92c952",
"url": "http://placehold.it/600/92c952"
},
"type": 1
},
"type": 2,
"ups": [
{
"creationDate": 1530110788904,
"description": "fofofof",
"id": 9,
"name": "product 19",
"price": 30,
"thumbnailUrl": "lll.lll",
"url": "http://ggg.ggg"
},
{
"creationDate": 1530110788904,
"description": "bdkdkkd",
"id": 13,
"name": "product 13",
"price": 120,
"url": "http://aaa.com"
}
]
},
{
"creationDate": 1530110788904,
"deliveryComp": "dhl",
"description": "officia delectus consequatur vero aut veniam explicabo molestias",
"id": 7,
"name": "product 7",
"price": 14,
"thumbnailUrl": "http://placehold.it/150/b0f7cc",
"type": 3,
"url": "http://placehold.it/600/b0f7cc"
},
{
"type": 2,
"ups": [
{
"creationDate": 1530110788904,
"description": "qui eius qui autem sed",
"id": 9,
"name": "product 9",
"price": 13,
"thumbnailUrl": "http://placehold.it/150/51aa97",
"url": "http://placehold.it/600/51aa97"
},
{
"creationDate": 1530110788904,
"description": "beatae et provident et ut vel",
"id": 10,
"name": "product 10",
"price": 111,
"thumbnailUrl": "http://placehold.it/150/810b14",
"url": "http://placehold.it/600/810b14"
}
]
})