Filters ng-repeat not working inside vs-repeat
See original GitHub issueKamilkp, thanks for this great directive. I was just wondering if it’s possible to use filter(s) inside your vs-repeat directive?
I tried the example below, but the provided default, custom filters dont filter anything. When used without your directive it works fine.
<ul vs-repeat="120" vs-offset-after="6" class="repeater-container">
<li ng-repeat="item in items | filter:MyFilter | filter:query">
{{item.name}}
...
...
</li>
</ul>
Issue Analytics
- State:
- Created 9 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Filter not working in ng-repeat - Stack Overflow
A filter on ng-repeat will only take into account what is in the object. Not what might be displayed while the loop is...
Read more >Be careful when using ng-repeat's $index - CodeUtopia
AngularJS best practices: Be careful when using ng-repeat's $index · A simple list with an action · Adding a filter · Using $index...
Read more >Angular-JS ng-repeat Directive - GeeksforGeeks
Angular-JS ng-repeat directive is a handy tool to repeat a set of HTML code for a number of times or once per item...
Read more >Dynamic filter within ng-repeat in AngularJS - iTecNote
For my AngularJS app I have an ng-repeat in an ng-repeat like so: Html: <div ng-app="myApp"> <div ng-controller="myController"> <h2>working filter</h2> <div ...
Read more >AngularJS to Angular concepts: Quick reference
The *ngFor directive in Angular is like the ng-repeat directive in AngularJS. It repeats the associated DOM element for each item in the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s entirely not the fault of
vs-repeat
. The problem is thatvs-repeat
creates new non-isolated scope. And if you write:you basically write to a
filtered
variable on the current scope. If you wrap it withvs-repeat
thefiltered
variable gets written intovs-repeat
’s scope not the outer scope. Writing like that:should fix the issue. Chceck out the updated gist: https://gist.github.com/kamilkp/40332795f8cf256772ce/revisions
I didn’t test it but i’m pretty sure it will work like that.
I did test it and you are once again correct. Nice trick to use the ng-init attribute! That’s one of the ng-attributes i never actually use, but in this case its handy.
Thanks again for the quick help!