Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

contidional orderBy only on init AngularJS

How can I run orderBy filter only once when my view is initialized? I don't want my list to be reordered during runtime.

<li ng-repeat="service in quote.services | orderBy:'index'" ></li>
like image 952
Gustavo Reyes Avatar asked Mar 13 '23 04:03

Gustavo Reyes


1 Answers

Use the orderBy as a filter in your controller instead:

app.controller('DemoCtrl', ['$scope', '$filter', function($scope, $filter){  
    $scope.quote.services = $filter('orderBy')($scope.quote.services, 'index');
}]);

See the filter docs for all the options.

like image 148
Ties Avatar answered Mar 23 '23 04:03

Ties