1

i want to filter my output based on the selected value in a component:

<select ng-model="showGroup.group">
   <option value="A">A</option>
   <option value="B">B</option>
</select>

My Data which i want to show:

  {
    "name" : "Steve",
    "group" : "A"
  },
  {
    "name" : "Bob",
    "group" : "B"
  },
  {
    "name" : "Peter",
    "group" : "B"
  },

If a "A" is selected then i should show only Steve and if "B" is selected it should show Bob and Peter!

My Outputcode:

<table>
  <tr ng-repeat="person in persons">
      <td>{{person.name | filter:showGroup}}</td>
  </tr>
</table>

The Controller only gets the data from a JSON file.

Why this is not working? With an <input> element it works fine?!

Do I need to write my own filter? How do i do that?

1
  • 1
    filter on showGroup.group Commented Mar 23, 2014 at 21:43

1 Answer 1

2

Your filter is not correct. Please view this Plunkr.

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

4 Comments

Did this answer help you? Let me know if this answer is incorrect. If this answer is correct and helped you, kindly accept the answer.
It helped me alot! Thats exactly what i'am looking for! Thank you!
I have checked your code at Plunkr and it worked, but it is not filtering the Date by group! It look through all element and not only group. Here i modified your example a little bit and now its not working: plnkr.co/edit/sltxetiDAXSK3fb7ueS1
Glad it helped you. I don't really understand what you mean by 'but it is not filtering the Date by group'. I was under the impression you just need to filter ppl by the group they belong to. Anyways, if you think the answer I gave is correct and it helped you, could you kindly mark this answer as the 'accepted answer' as explained here meta.stackexchange.com/a/5235 ?

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.