Friday, 27 November 2015

Apply track by index and filter for ng-repeat: Angular

Angular default ng-repeat doesn't allow duplicate, for avoiding this you can add track by $index. You can read more about track by $index in angular js document

<div ng-repeat="user in userList track by $index">

For applying filter you may try below code

<div ng-repeat="user in userList track by $index | filter:search">

But it is not correct, filter should be done before applying track by $index.

<div ng-repeat="user in userList | filter:search track by $index">

Whenever you are applying filter along with track by $index follow above one .You can have multiple filters.

Related Posts

1. Angular js client side pagination like google.

2. Angular Loader using font awesome icons

3. Angular js add class to active element

No comments :

Post a Comment