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>