我做了一个猛击来演示我的问题:
http://plnkr.co/edit/sT9cFUFPhR2Z45SiRW7V?p=preview
如果搜索是新的搜索,它似乎会更新计数,但一旦所有内容都被缓存,它就会停止更新计数。似乎没有办法清除ng repeat的缓存(据我所知),我也不确定是否真的要这么做,因为这会影响性能。
有没有办法保持在一个或多个ng重复中显示的总行的最新计数?
HTML格式:

  <body ng-app="app">
    <div ng-controller="ctrl as c">
      <h1>{{'Count: ' + (c.count + c.count2)}}</h1>

      Search by name: <input type="text" ng-model="name">

      <div ng-repeat="name in c.names | filter:name" ng-init="c.count = $index + 1;">
          {{name}}
      </div>
      <div ng-repeat="name in c.names2 | filter:name"  ng-init="c.count2 = $index + 1;">
          {{name}}
      </div>
    </div>
  </body>
</html>

Javascript代码:
var app = angular.module('app', []);
app.controller('ctrl', function(){
  var c = this;
  c.count = 0;
  c.names = ['jim', 'james', 'fred', 'lue'];
  c.names2 = ['jim2', 'james2', 'fred2', 'lue2'];
});

最佳答案

将筛选的数组设置为临时变量并对其计数。
Plunker

<div ng-controller="ctrl as c">

<h1>Count: {{c.filtered1.length + c.filtered2.length}}</h1>
Search by name:
<input type="text" ng-model="name">

<div ng-repeat="name in c.filtered1 = (c.names | filter:name)">
  {{name}}
</div>

<div ng-repeat="name in c.filtered2 = (c.names | filter:name)">
  {{name}}
</div>

</div>

09-26 01:47