angularjs-orderby

Angularjs wrong $index after orderBy

前提是你 提交于 2019-11-26 12:37:22
问题 I am new to Angular.js and have some problems sorting my array and working on that sorted data. I have a list with items and want so sort it by \"Store.storeName\", which is working so far. But after sorting the data, my delete-function is not working anymore. I think thats because the $index is wrong after sorting, and so the wrong data is deleted. How can I solve that? Ordering the data in the scope and not in the view? How to do that? Here is some relevant code: In the View: <tr ng-repeat=

random orderBy in AngularJS 1.2 returns &#39;infdig&#39; errors

一世执手 提交于 2019-11-26 12:32:55
问题 Using the random orderBy sort technique in this question works fine in AngularJS 1.1. var myApp = angular.module(\'myApp\',[]); function MyCtrl($scope) { $scope.list = [\'a\', \'b\', \'c\', \'d\', \'e\', \'f\', \'g\']; $scope.random = function() { return 0.5 - Math.random(); } } In 1.2, though, it puts infdig errors into the console and takes a much longer time to return the sorted results: http://jsfiddle.net/mblase75/jVs27/ The error in the console looks like: Error: [$rootScope:infdig] 10

orderBy multiple fields in Angular

家住魔仙堡 提交于 2019-11-26 04:32:07
问题 How to sort by using multiple fields at same time in angular? fist by group and then by sub-group for Example $scope.divisions = [{\'group\':1,\'sub\':1}, {\'group\':2,\'sub\':10}, {\'group\':1,\'sub\':2},{\'group\':1,\'sub\':20},{\'group\':2,\'sub\':1}, {\'group\':2,\'sub\':11}]; I wanted to display this as group : Sub-group 1 - 1 1 - 2 1 - 20 2 - 1 2 - 10 2 - 11 <select ng-model=\"divs\" ng-options=\"(d.group+\' - \'+d.sub) for d in divisions | orderBy:\'group\' | orderBy:\'sub\'\" /> 回答1: