Skip to content

Instantly share code, notes, and snippets.

@lossendae
Created May 26, 2014 18:18
Show Gist options
  • Save lossendae/64b5ceb41b90382cb0be to your computer and use it in GitHub Desktop.
Save lossendae/64b5ceb41b90382cb0be to your computer and use it in GitHub Desktop.
Angular filter in ng-repeat with sum on value length
<!-- If I want to hide done todos -->
<ul class="whatever">
<li data-ng-repeat="todo in todos | filter:{done: false}">
...
</li>
</ul>
<!-- Show done todos -->
<div class="whatever" data-ng-show="(todos | filter:{done: true} ).length > 0">
...
</div>
<!-- sums -->
<div class="whatever">
<div>All: {{todos.length}}</div>
<div>Incomplete: {{(todos | filter:{done: false}).length}}</div>
<div>Done: {{(todos | filter:{done: true}).length}}</div>
</div>
There is more here : http://jsfiddle.net/mhevery/bpTXe/148/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment