efsnick
efsnick

Reputation: 101

Angularjs custom filter with expression alias and limitTo

I am using ng-repeat to show all items in an result set. I have a custom search box which filters out results via a custom filter. I now need to add pagination, but I also need all the items in the result set to be searchable, regardless of pagination. Here is the code:

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

According to the ng-repeat documentation: https://docs.angularjs.org/api/ng/directive/ngRepeat, It seems that the "as" micro-syntax can only be used at the end. limitTo of course has to be after the filter in order for items to be searchable. Anyone had this issue before?

Upvotes: 3

Views: 2040

Answers (1)

efsnick
efsnick

Reputation: 101

The answer found in the link below allowed me to keep my alias and achieve the desired result.

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

Upvotes: 3

Related Questions