1

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.

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

thanks for your simple answer...it's works for me...thanks
I am glad I was able to help.
1

Try to do this Demo

 <input type="text" name="kpcategory" 
      data-ng-model="kpcategory.category" value="kpcategory">

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

Note: I have made data-ng-model="kpcategory.category" in the input field

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.