Contidional orderBy only on init AngularJS

How can I run the orderBy filter only once when my view is initialized? I do not want my list to be reordered at runtime.

<li ng-repeat="service in quote.services | orderBy:'index'" ></li>
+1
source share
1 answer

Instead, use orderBy as a filter in your controller:

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

Refer to the filter files for all parameters.

+4
source

Source: https://habr.com/ru/post/1676707/


All Articles