AngularJS filter exact values with length -


what want count filter length of array of objects particular property based on repeater scope. code technically works (it displays correct count of filter):

<li ng-repeat="question in questions" id="{{ question.id }}">     {{ question.text }}     <ul>         <li ng-repeat="answer in question.answers" id="{{ answer.id }}">             {{ answer.text }} (<span ng-controller='answerscontroller'>{{ (useranswers|filter:{answer_id:answer.id}).length }}</span>)          </li>     </ul>  </li> 

the problem is, when scope id 1 (for example), matches on 1,10,11,21, etc. i'd make exact code have above work on exact match.

please let me know supporting code helpful.

you have angular want strict comparaison. that's easy angular 1.1.5, because filter filter (see documentation) has third parameter, comparator, true usefull shorthand. in case, can make :

<li ng-repeat="question in questions" id="{{ question.id }}">     {{ question.text }}     <ul>         <li ng-repeat="answer in question.answers" id="{{ answer.id }}">             {{ answer.text }} (<span ng-controller='answerscontroller'>{{ (useranswers|filter:{answer_id:answer.id}:true).length }}</span>)          </li>     </ul>  </li> 

Comments