2017-05-11 51 views
0

上查看網頁,我已經使用過濾器是這樣的:ORDERBY不customOrder工作的角度JS

<div class="col-md-3" ng-repeat="product in vendorProducts.offers | orderBy:customOrder" ng-if="vendorProducts.offers.length > 0"> 

在控制器,我已經創建自定義過濾器:

$scope.customOrder = function (item) { 
    var filtered = []; 

    angular.forEach($scope.cRoomProducts, function(cRoomProduct) { 
     var vproduct = _.find($scope.vendorProducts.offers,function(vp){ return vp._id == cRoomProduct.offerDetails[0]._id }) 
     filtered.push(vproduct) 
    }); 

    var remainOfferProduct = $scope.vendorProducts.offers.filter(function(x) { return filtered.indexOf(x) < 0 }) 
    filtered = filtered.concat(remainOfferProduct) 
    return filtered; 
    }; 

越來越數組在已過濾,但數據仍未排序。 任何幫助,高度讚賞。我有兩個數組。我想首先使用第一個數組的數據對數據進行排序。 $ scope.cRoomProducts數據首先所以,我已經相應地過濾了數據。並且想要對vendorProducts.offers的數據進行排序。

+0

'filtered'包含'vendorProducts.offers'項目排序? –

+0

@ Alexandru-IonutMihai。已過濾包含vendorProducts.offers的已排序項目的數組 – user100693

+0

要按哪個字段進行排序? –

回答

0

更改爲

ng-repeat="product in vendorProducts.offers | filter:customOrder"