Angularjs自定义过滤器,带有表达式别名和limitTo

时间:2017-01-12 18:48:33

标签: angularjs ng-repeat

我正在使用ng-repeat来显示结果集中的所有项目。我有一个自定义搜索框,可以通过自定义过滤器过滤掉结果。我现在需要添加分页,但我也需要搜索结果集中的所有项目,无论分页如何。这是代码:

<div 
ng-repeat=
"items in obj | filter : {ownerId: controller.ownerId}
 | customSearchFilter : controller.searchText as filteredResults | limitTo: controller.paginationLimit
"></div>

根据ng-repeat文档:https://docs.angularjs.org/api/ng/directive/ngRepeat,似乎&#34; as&#34;微语法只能在最后使用。 limitTo当然必须在过滤器之后才能搜索项目。以前有人遇到过这个问题吗?

1 个答案:

答案 0 :(得分:3)

以下链接中的答案让我保留了别名并达到了预期的效果。

https://stackoverflow.com/a/11722324/1520950