Monday, June 29, 2015

AngularJS orderby Filter

AngularJS filters are used to format/transform the data displayed in the view, filters can be used with expressions, ng-bind, ng-repeat etc and act upon the data from the model. The orderby filter is used to sort a list of elements in an array / collection, this comes in handy when we want to implement sorting feature in a table/list in the view.

The following is the syntax for using orderby filters
<li ng-repeat="<collection> | orderBy:'<column>'">

The following is an example of using orderby filters.
<html ng-app>
    <meta charset="utf-8" />
    <title>AngularJS - Basic</title>
    <script src="angular.min.js"></script>
          <div ng-init="Employees=[
                       <li ng-repeat="emp in Employees | orderBy:'Name'">
                         {{ }} - {{ emp.Name }}<br/>


Search Flipkart Products:

No comments: