条件顺序仅在 init AngularJS
contidional orderBy only on init AngularJS
如何在我的视图初始化时 运行 orderBy 只过滤一次?我不希望我的列表在 运行 时间内被重新排序。
<li ng-repeat="service in quote.services | orderBy:'index'" ></li>
改为在控制器中使用 orderBy 作为过滤器:
app.controller('DemoCtrl', ['$scope', '$filter', function($scope, $filter){
$scope.quote.services = $filter('orderBy')($scope.quote.services, 'index');
}]);
查看所有选项的filter docs。
如何在我的视图初始化时 运行 orderBy 只过滤一次?我不希望我的列表在 运行 时间内被重新排序。
<li ng-repeat="service in quote.services | orderBy:'index'" ></li>
改为在控制器中使用 orderBy 作为过滤器:
app.controller('DemoCtrl', ['$scope', '$filter', function($scope, $filter){
$scope.quote.services = $filter('orderBy')($scope.quote.services, 'index');
}]);
查看所有选项的filter docs。