angularjs - How to dynamic count how many times ng-repeat repeated? -


quick question how appropriately count record have been repeated in view?

here view:

<h4> drafts </h4> <ul class="nav nav-pills scrollable-nav">   <li ng-repeat="solution in solutions | filter: {'username': username}: true | filter: {visible: false} ">       <a href="#" onclick="return false;">       <h5 ng-click="editsolution(solution.$id)">{{solution.name}}</h5>     </a>    </li>                             </ul> 

and number how many time solution repeated? user can change solution.visible value true anytime, need dynamically display number.

i can use variable in scope track number, wondering if there other better ways it?

you create temporary variable hold value of filtered result

<li ng-repeat="solution in filteredsolutions = (solutions | filter: {'username': username, visible: false}: true)"> 

then {{filteredsolutions.length}} count

you use alternative way aliasing filtered result @claies suggested, supported in angular 1.3+

<li ng-repeat="solution in solutions | filter: {'username': username, visible: false}: true filteredsolutions"> 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -