Questions tagged [angularjs-orderby]

Orders a specified array by the expression predicate (Angular.js)

Orders a specified array by the expression predicate. It is ordered alphabetically for strings and numerically for numbers. Note: if you notice numbers are not being sorted correctly, make sure they are actually being saved as numbers and not strings.

Usage
In HTML Template Binding

{{ orderBy_expression | orderBy : expression : reverse}}

In JavaScript

$filter('orderBy')(array, expression, reverse)

Reference:
https://docs.angularjs.org/api/ng/filter/orderBy

262 questions
391
votes
8 answers

orderBy multiple fields in Angular

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}, …
gmeka
  • 4,269
  • 3
  • 25
  • 25
92
votes
6 answers

Angularjs wrong $index after orderBy

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…
FuzzBuzz
  • 999
  • 1
  • 7
  • 7
50
votes
3 answers

How to sort object data source in ng-repeat in AngularJS?

Suppose I have the following users: $scope.users = { "2": { email: 'john@gmail.com', name: 'John' }, "3": { email: 'elisa@gmail.com', name: 'Elisa' } } I would like to create a
T.Ho
  • 1,190
  • 3
  • 11
  • 16
31
votes
1 answer

orderBy not working as expected: Angularjs

My array is : BS. Its structure is : Array[317] 0: Object $$hashKey: "022" name: "Los Angeles Comm." . . . .. BS is an array. Each value is a JSon object with filed of name. I want to sort all the values of BS according to their name. I am…
Bhumi Singhal
  • 8,063
  • 10
  • 50
  • 76
17
votes
3 answers

Custom order using orderBy in ng-repeat

I have objects like this: students = {name: 'Aa_Student', class: 'A_Class'}, {name: 'Ab_Student', class: 'A_Class'}, {name: 'Ac_Student', class: 'B_Class'}, {name: 'Ba_Student', class: 'B_Class'}, {name:…
Kimchi Man
  • 1,131
  • 3
  • 13
  • 24
16
votes
8 answers

Disabling orderBy in AngularJS while editing the list

After applying orderBy in my list of input boxes if i edit any field it starts sorting immediately and i loose focus. I tried to dug in the angular code and found out they have applied something like $watch on the orderBy's attributes therefore…
I_Debug_Everything
  • 3,776
  • 4
  • 36
  • 48
11
votes
1 answer

AngularJS Paging orderBy only affects displayed page

Can anyone point me in the right direction to figure out a way to fix the way paging and orderBy work together in Angular? Currently, I can orderBy and page the results of the data[], but the orderBy filter only affects the each page individually.…
Logan W
  • 1,367
  • 3
  • 18
  • 24
10
votes
3 answers

dates not properly sorted in Angular.js

I am relatively new to Angular.js and am having a problem with date sorting. I have looked around the web for similar issues, but haven't found any that are of quite the same flavor. The situation is as follows: I am getting a data set back from…
Documental
  • 101
  • 1
  • 1
  • 4
8
votes
4 answers

How to orderBy a array of objects in descending order in angularjs?

I have a very simple array of objects and I want to sort it using $filter('orderBy') in javascript. Somehow it doesn't seem to work. jsFiddle Here is the code var app = angular.module('myApp', []); app.controller('myController', function($scope,…
Saras Arya
  • 3,022
  • 8
  • 41
  • 71
8
votes
2 answers

Error 'orderBy' when updating to Angular 1.5.3

I updated Angular on my project, from 1.4.9 to 1.5.3. And on one of the pages I'm getting this error message: 'Error: orderBy:notarray Value is not array-like', 'Expected array but received: 0' Here is template:
8
votes
2 answers

OrderBy Date values, which are just strings in Angular JS

I'm trying to order some data by date, although the dates are just strings, in the format dd-mm-yyyy. I made a filter which converted the plain string of numbers (which where in the US date format, where I wanted the UK date format) e.g 01272012 to…
user3350593
8
votes
1 answer

Angularjs - using orderby filter in the controller's scope

I have an array of objects i.e. filtered and paged and now I would like to order the list items by different object attributes. I tried the orderBy filter as follows:
Amyth
  • 32,527
  • 26
  • 93
  • 135
7
votes
3 answers

ng-repeat orderBy keeping fixed top value

see the fiddle here http://jsfiddle.net/prantikv/gcz4gwgw/1/ i want to get one i item on the top of the list and the rest in alphabetical order:
  • {{value.name}}
krv
  • 2,830
  • 7
  • 40
  • 79
1
2 3
17 18