Solved

angularjs orderby function question

Posted on 2014-11-19
2
256 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
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now