vendredi 26 mai 2017

Angular OrderBy in Controller not sorting

I just cannot get sorting to work for this project I am working on. I am trying to use orderBy injection into controller per instructions on AngularJs site http://ift.tt/RoC35d. I am using chrome and I can see my sort method being hit properly but no sort occurs. Also I get no errors. I have checkboxes in a table and want to sort by selected checkboxes, however, I cannot have checkboxes be sorted dynamically. I do have this working in my proof of concept in Plunker http://ift.tt/2r0L8Vo

Here is my sample code.

.JS file code below

angular.module('multiRecipientDeliveryApp').controller(controllerId,
        ['$scope', 'appConfig', 'orderByFilter', '$state', '$modal', 'multiRecipientDeliveryService', deliveryListCreateController]);

function deliveryListCreateController($scope, appConfig, orderByFilter, $state, $modal, multiRecipientDeliveryService)

Here is the sort method used.

$scope.sortOrder = function (column) {

            $scope.reverseSort = ($scope.sortColumn == column) ? !$scope.reverseSort : false;
            $scope.sortColumn = column;   
            $scope.visibleAddresses = orderByFilter($scope.visibleAddresses, $scope.sortColumn, $scope.reverseSort);
        };   

Here is the HTML code used and I suspect here in lies my problem.

<tr ng-repeat="address in visibleAddresses = ((filteredAddresses = ( addresses | filter: {Description:description, Region:region, Attn:attn, Address1:address1, Address2:address2, City:city, State:state, Zip:zip}) | startFrom:(currentPage-1)*pageSize | limitTo:pageSize ))" on-finish-render="0" ng-click="addressClicked(address)" ng-class="{ active: addressIsSelected(address) }">

Here is the call to the sort method from HTML.

<th><span ng-click="sortOrder('IsSelected')">CheckBoxSort</span></th>

Any insight to how to get this to work would be appreciated. Note, adding "OrderBy" to the filter on the HTML file is not an option, as I wish to avoid dyanamic sorting. Hope that makes sense.




Aucun commentaire:

Enregistrer un commentaire