Search code examples
htmlangularjsmeanjs

How to filter ng-repeat values based on another input ng-model value in angularjs?


repeat values based on another input ng-model value in angularjs?

  • I have one input value like Social Psychology for this value ng-model is kpcategory

  • I have used ng-repeat like ng-repeat="question in questions to list out the all category and name.

  • I tried to filter Social Psychology category in ng-repeat list, so i used like ng-repeat="question in questions | filter:kpcategory".
  • what the issue is, it's filtering Social Psychology data's perfectly. but i would like to filter only the category value of Social Psychology not for all data's. the issue is it's filtered includes of category and category_twodata's.

Expecting result is:-

  • just want to filter by catgory Social Psychology so result should be Social Psychology , John data.

  • My Plunker For Reference

  • we don't how to solve this issue please help us thanks.


Solution

  • You can try following to filter items by category property only

      <div ng-repeat="question in questions | filter:{ category: kpcategory }">
          <ul>
              <li><span>{{question.category}} , {{question.name}}</span></li>
          </ul>     
      </div>
    

    Demo