Cameron Cameron - 1 year ago 82
Javascript Question

What does equals in ngRepeat do?

What does the equals in the

attribute value mean?

<li ng-repeat="person in people = (people | orderBy: firstname)">

instead of doing:

<li ng-repeat="person in people | orderBy: firstname">

I can't see any examples explaining its use in the documentation for ngRepeat.

Answer Source

It is usefull for count how many objects were filtered, eg.

function People($scope) {
  $scope.people = [{
    firstname: 'a'
  }, {
    firstname: 'c'
  }, {
    firstname: 'b'
  }, {
    firstname: 'c'
<script src=""></script>

<div ng-app ng-controller="People">
    <li ng-repeat="person in filteredPeople = (people | filter: 'c')">{{person.firstname}}</li>
  Total filtered: {{ filteredPeople.length }}

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