user1851003 user1851003 - 1 year ago 108
Javascript Question

sorting of email-ID's using angular Filters

I am new to angular Filters.

If i want to sort the email Id's which is in ng-repeat by applying a filter. How to do this?

For example :, , and are my emails.

I want to get the output as ,, ,

Its like sorting alphabetically and also in ascending order Both in a filter.

I would really appreciate if working code is provided for this.

Thanks in advance. What I should write in OrderBy: "???????"


<div class="col-md-12 " ng-repeat="e in allEmails | orderBy:'??????'">
//Display the emails here in sorted alphabetically ascending order.

Answer Source

Try this,

var app = angular.module('myapp', []);

app.controller('MainCtrl', function($scope) {
  $scope.emails =  ['', '', '', '']
<script src=""></script>

<body ng-app="myapp" ng-controller="MainCtrl">
      <li ng-repeat="email in emails |orderBy:'toString()'">

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download