Sharing Top Content from the Angular-sphere.

angularjs orderBy and bring item to top

  • & lt ; p & gt ; Custom sort by name , then move current to top: & lt ; / p & gt ;
  • I want an aphebetical list by username and the current user to be displayed at the top.
  • Now to get the current user to display at the top we can do this in a custom filter.
  • Update 31/07/2014: Added orderBy:’username’ which sorts the list before moving the current user to top.
  • What I meant was that the final example says “Custom sort by name, then move current to top” and in the HTML you have data-ng-repeat=”u in users | currentUserToTop:user.id”.

Read the full article, click here.


@angularjs4u: “angularjs orderBy and bring item to top #filters”


In your completed example you’re missing orderBy:’username’ to sort it by name as well as move current user to top. Also in line 5 of your JavaScript there’s a random if ( that never closes


angularjs orderBy and bring item to top

Comments are closed, but trackbacks and pingbacks are open.