javascript – ngRepeat中的equals是什么?

前端之家收集整理的这篇文章主要介绍了javascript – ngRepeat中的equals是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
ng-repeat属性值中的等于是什么意思?
<li ng-repeat="person in people = (people | orderBy: firstname)">

而不是做:

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

我看不到任何解释它在ngRepeat文档中使用的例子.

解决方法

计算有多少对象被过滤是有用的,例如.
function People($scope) {
  $scope.people = [{
    firstname: 'a'
  },{
    firstname: 'c'
  },{
    firstname: 'b'
  },{
    firstname: 'c'
  }]
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

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

猜你在找的JavaScript相关文章