Cameron Cameron - 6 months ago 3x
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.


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 }}