angularjs-orderby

Custom order using orderBy in ng-repeat

老子叫甜甜 提交于 2020-01-09 13:04:54
问题 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: 'Bb_Student', class: 'C_Class'}, {name: 'Bc_Student', class: 'C_Class'} Let's say the students object is shuffled. I use ng-repeat to show the data. I want to sort the objects in the custom order. For example, I want to show the data like this: Name Class ----------------------------- Ac

AngularJS Paging orderBy only affects displayed page

馋奶兔 提交于 2020-01-01 02:32:49
问题 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. For example, if I sort in reverse order by ID, page 1 will list 10-1, and page 2 will list 15-11, as opposed to starting with 15 and going to 1 by the end of the second page. I have a basic fiddle here http://jsfiddle.net/ZbMsR/ Here is my

Angular UI Bootstrap Typeahead does not working for filter and orderBy

空扰寡人 提交于 2019-12-25 08:58:28
问题 Is there any option to use typeahead search the item name when the item details are coming from another JSON object ? Demo: http://codepen.io/anon/pen/PGWvmE The other filter and orderBy working fine, but I couldn't find solution for the item search from typeahead with orderBy and filter based on the selected items from the list angular.module('mytodos', ['ui.bootstrap']).controller('TodoController', function($scope) { $scope.changeNum = function(itemNum) { $scope.numPerPage = itemNum; };

AngularJS orderBy date

房东的猫 提交于 2019-12-23 02:36:24
问题 I have something like this: <div ng-repeat="i in inv"> <p>{{i.dueDate}}</p> </div> I'd like to order by oldest date first. I know there's a way to do it but I can't figure it out. Can anyone help? Here is the sample js: $scope.inv = [ { name: "Paul", dueDate: "5/21/2014" }, { name: "Dan", dueDate: "5/22/2014" }, { name: "Randy", dueDate: "1/12/2015" } ]; 回答1: You have to define a customizer function, then use it in orderBy expression. For example: $scope.dueDateFormatter = function(i) { var

Why are the advantages or filter and orderBy?

余生长醉 提交于 2019-12-21 04:27:47
问题 It seems that AngularJS really puts an heavy emphasis on using filters and other ng directive in your view to filter and sort your data, instead of doing it manually in the model. Is there any reason for that, ie is it faster, cached, or something? I want to show a list sorted for example, but I also want to access the sorted list for other purposes that are not view related. It's very easy if the list is directly sorted in the model, so I'm trying to understand if there is a drawback to

OrderBy Date values, which are just strings in Angular JS

非 Y 不嫁゛ 提交于 2019-12-19 06:27:25
问题 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 27-01-2014, but when I try to order them it still only sees them as numeric strings, so 01-01-1990 would come before 02-01-2014. Any suggestions of how to do this in a filter? Thanks! Update I figured out the dates would automatically get orderedif

dates not properly sorted in Angular.js

旧街凉风 提交于 2019-12-18 20:48:13
问题 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 the database (that I would like to display in a column-header sortable table), in which each record contains a date formatted as a string: data = [ { "name": "Test_1_Test", "creation_date": "8/2/2013 10:31:02 AM" }, { "name": "Test_2_Test", "creation

Orderby not working with dict syntax on ng-repeat

≯℡__Kan透↙ 提交于 2019-12-17 16:25:04
问题 I am trying to use ng-repeat with a dictionary style syntax and apply an order to the key value. (key, value) in something | orderBy:'key' It seems OrderBy isn't working as expected Example here http://jsfiddle.net/mhXuW/ 回答1: The parameters to orderBy must match property names in an array of objects. Your data needs to look something like this: $scope.list2 = [ { id:"2013-01-08T00:00:00", name:'Joe'}, { id:"2013-01-09T00:00:00", name:'Sue'}]; Then a filter like this will work: <div ng-repeat

deleting an element in ng-repeat with orderBy and track by is failing

主宰稳场 提交于 2019-12-13 05:58:19
问题 Here is the code <tr ng-repeat="collection in collections | orderBy:'-modifiedDate' track by $index" ng-init="listIndex = $index"> If I remove orderBy:'-modifiedDate' , the deletion on a specific element is working great. However, I need the collection/array to be rendered in sorted way that's why I have orderBy. If I don't delete the orderBy:'-modifiedDate' from the code and I delete a random element say on position 7, the element that gets deleted is the very last always. I had to use ng

How do I create a callback for ng-repeat orderBy?

霸气de小男生 提交于 2019-12-12 21:26:08
问题 Looking for a way to get AngularJS'a ng-repeat orderBy filter to do a callback once it's done rendering... Markup: <div ng-controller="MyCtrl"> <table> <thead> <tr> <th ng-click="sort('name')">Name:</th> <th ng-click="sort('age')">Age:</th> </tr> </thead> <tbody> <tr ng-repeat="item in items | orderBy:sortColumn:reverseSort"> <td>{{item.name}}</td> <td>{{item.age}}</td> </tr> </tbody> </table> </div> JS: var myApp = angular.module('myApp', []); function MyCtrl($scope) { $scope.items = [{