Tuesday, June 25, 2013

AngularJS - Ordering a set of results - Basic version

In the following example, we let the user select from a drop down list the order criteria he/she wants to apply. The we iterate over our results and apply the selected order. Angular is actually reordering the set based on property name matching. As long as the string representing the order criteria matches a property in our iterated elements (person in this example), the magic occurs.

    <div>
<h3>Order By:</h3>
<select data-ng-model='selectedSortOrder'
data-ng-options="option for option in ['name', 'lastName', 'age']"
data-ng-init="selectedSortOrder='name'">
</select>
</div>
<div >
<h3>List of results:</h3>
<div ng-repeat="person in results | orderBy:selectedSortOrder">
{{person.name}} {{person.lastName}} - {{person.age}}
</div>
</div>

Note:

Useful links:

Working Example: Plunkr

14 comments:

  1. Pretty blog, so many ideas in a single site, thanks for the informative article, keep updating more article.
    hadoop training in chennai

    angularjs training in chennai

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area. We are providing AngularJS training in Velachery.

    For more details:AngularJS training in chennai

    ReplyDelete
  4. Thanks a lot very much for the high quality and results-oriented help.I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
    Visit Us: http://www.zerobugacademy.com/angularjs-training-in-chennai

    ReplyDelete
  5. Marvelous and fascinating article. Incredible things you've generally imparted to us. Much obliged. Simply keep making this kind out of the post.

    angularjs training in chennai

    ReplyDelete

  6. This blog really very help full for all developers and students thank you for writing this blog and now angularjs 6 very training development language more job opportunities available all development company's thank once.

    Angularjs training in chennai | Angularjs training in velachery

    ReplyDelete

  7. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging


    AngularJs Training in Electronic City

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Looking For Flutter App Development Flutter is Google's mobile UI framework for crafting high-quality native interfaces on iOS and Android in record time. With the release of Flutter 1.12 version, the programming language has been updated from Dart 2.5 to Dart 2.7. It is expected to supply excellent development and user experience.

    ReplyDelete
  10. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    angular js online training
    best angular js online training
    top angular js online training

    ReplyDelete