Solved

angularjs orderby function question

Posted on 2014-11-19
2
286 Views
Last Modified: 2014-12-04
I need a orderby function where if the usertype is a user, order by lastname, firstname.  If it is a person, orderby lastname, firstname, if it is a entity orderby the label.

They have the same object called contact, and the userType field distinguishes between user, person, and entity.  Also the order that it should show in is user, person, entity.
0
Comment
Question by:cbrune
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40455248
I don't understand what you mean by "function".  Are you talking about a directive?
0
 
LVL 22

Accepted Solution

by:
ambience earned 500 total points
ID: 40457830
You probably need the orderBy filter for that purpose, which is documented here https://docs.angularjs.org/api/ng/filter/orderBy

According to the documentation, orderby accepts an array of function or string predicates. The first predicate in the array is used for sorting, but when two items are equivalent, the next predicate is used.

Filter is especially more relevant when sorting is needed for presentation only. However, using the $filter you can even get the builtin orderBy and invoke it directly in controller code.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question