angularjs filter如何筛选
数据类型vararr=[{id:1,value:"test1"},{id:2,value:"test2"},{id:3,value:"test3"},{id:4,valu...
数据类型var arr = [{id: 1, value: "test1"}, {id: 2, value: "test2"}, {id: 3, value: "test3"}, {id: 4, value: "test4"}]。
如果是找到id=3的,{{arr | filter: {id: 3}: true}}就可以了,如果要找到3和4的,如何写?
{{arr | filter: {id: 3}: true | filter: {id: 4}: true}}这样是与的关系,筛选出来的数据是空,如何筛选出或的关系? 展开
如果是找到id=3的,{{arr | filter: {id: 3}: true}}就可以了,如果要找到3和4的,如何写?
{{arr | filter: {id: 3}: true | filter: {id: 4}: true}}这样是与的关系,筛选出来的数据是空,如何筛选出或的关系? 展开
1个回答
展开全部
{{ [{"age": 20,"id": 10,"name": "iphone"},
{"age": 12,"id": 11,"name": "sunm xing"},
{"age": 44,"id": 12,"name": "test abc"}
] | filter:'s'}} //查找含有有s的行
//上例结果:[{"age":12,"id":11,"name":"sunm xing"},{"age":44,"id":12,"name":"test abc"}]
{{ [{"age": 20,"id": 10,"name": "iphone"},
{"age": 12,"id": 11,"name": "sunm xing"},
{"age": 44,"id": 12,"name": "test abc"}
] | filter:{'name':'iphone'} }} //查找name为iphone的行
//上例结果:[{"age":20,"id":10,"name":"iphone"}]
{"age": 12,"id": 11,"name": "sunm xing"},
{"age": 44,"id": 12,"name": "test abc"}
] | filter:'s'}} //查找含有有s的行
//上例结果:[{"age":12,"id":11,"name":"sunm xing"},{"age":44,"id":12,"name":"test abc"}]
{{ [{"age": 20,"id": 10,"name": "iphone"},
{"age": 12,"id": 11,"name": "sunm xing"},
{"age": 44,"id": 12,"name": "test abc"}
] | filter:{'name':'iphone'} }} //查找name为iphone的行
//上例结果:[{"age":20,"id":10,"name":"iphone"}]
追问
我想要结果是 age : 20 及 age: 44的 该如何写filter这里?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询