Angularjs 如何计算值等于ng repeat的元素

Angularjs 如何计算值等于ng repeat的元素,angularjs,ng-repeat,Angularjs,Ng Repeat,如何计算ng repeat中与变量相等的元素 例如,我有一个ng重复,我想计算Fund.status等于“Finish”或“Todo”的每个元素: {{Fund.id} {{基金受益人} {{Fund.Title} {{基金状况} {{基金.类别} {{FormField.shortDate(Fund.CreationDate)} {{FormField.shortDate(Fund.DueDate)} {{基金.团队} {{基金官员} 你可以这样做,但这是一种不好的做法。在重复ng的过程中,

如何计算ng repeat中与变量相等的元素

例如,我有一个ng重复,我想计算Fund.status等于“Finish”或“Todo”的每个元素:


{{Fund.id}
{{基金受益人}
{{Fund.Title}
{{基金状况}
{{基金.类别}
{{FormField.shortDate(Fund.CreationDate)}
{{FormField.shortDate(Fund.DueDate)}
{{基金.团队}
{{基金官员}

你可以这样做,但这是一种不好的做法。在重复ng的过程中,在你的视野中数东西是令人讨厌的。您最好在控制器中进行计数,并将结果显示给视图,就像这样

$scope.thoseThatEqualFundOrTodo = function(items){
  return _.find(items, function(item){
     item.status === 'Todo' || item.status === 'Fund';
  }).length;
});
然后在模板中,您可以执行以下操作:

<table data-scope-attribute="filteredTasks" data-scope-attribute-watch="ListTask| filter:TreeFilter |orderBy:orderByField:reverseSort">

Result:  {{thoseThatEqualFundOrTodo(filteredTasks)}}

<tbody ng-repeat="Fund in filteredTasks">
                        <tr ng-dblclick="open(Fund.id,Fund)" data-toggle="modal" data-target="{{Fund.type}}">
                            <td>{{Fund.id}}</td>
                            <td>{{Fund.Beneficiary}}</td>
                            <td>{{Fund.Title}}</td>
                            <td>{{Fund.status}}</td>
                            <td>{{Fund.category}}</td>
                            <td>{{FormField.shortDate(Fund.CreationDate)}}</td>
                            <td>{{FormField.shortDate(Fund.DueDate)}}</td>
                            <td>{{Fund.Team}}</td>
                            <td>{{Fund.Officer}}</td>
                        </tr>
                    </tbody>
</table>

结果:{{thoseThatEqualFundOrTodo(filteredTasks)}
{{Fund.id}
{{基金受益人}
{{Fund.Title}
{{基金状况}
{{基金.类别}
{{FormField.shortDate(Fund.CreationDate)}
{{FormField.shortDate(Fund.DueDate)}
{{基金.团队}
{{基金官员}

我也尝试过,但没有成功。我确实有一个错误,因为它不知道。找到它说[$interpolate:interr]不能插值:当然不能,我正在使用它进行过滤。你应该自己做过滤,只需循环项目。。。
<table data-scope-attribute="filteredTasks" data-scope-attribute-watch="ListTask| filter:TreeFilter |orderBy:orderByField:reverseSort">

Result:  {{thoseThatEqualFundOrTodo(filteredTasks)}}

<tbody ng-repeat="Fund in filteredTasks">
                        <tr ng-dblclick="open(Fund.id,Fund)" data-toggle="modal" data-target="{{Fund.type}}">
                            <td>{{Fund.id}}</td>
                            <td>{{Fund.Beneficiary}}</td>
                            <td>{{Fund.Title}}</td>
                            <td>{{Fund.status}}</td>
                            <td>{{Fund.category}}</td>
                            <td>{{FormField.shortDate(Fund.CreationDate)}}</td>
                            <td>{{FormField.shortDate(Fund.DueDate)}}</td>
                            <td>{{Fund.Team}}</td>
                            <td>{{Fund.Officer}}</td>
                        </tr>
                    </tbody>
</table>