[英]Using Selected Values to Filter Data with angularjs
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! 如果选择了“ A”,那么我应该只显示史蒂夫,如果选择“ B”,则应该显示Bob和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. Controller仅从JSON文件获取数据。
Why this is not working? 为什么这不起作用? With an
<input>
element it works fine?! 使用
<input>
元素可以正常工作吗?
Do I need to write my own filter? 我需要编写自己的过滤器吗? How do i do that?
我怎么做?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.