【发布时间】:2017-01-06 20:02:20
【问题描述】:
首先:Plunkr Example is here<-- NOW: WORKING EXAMPLE (edited)
这是数据:
[
{
"label": "One",
"value": 1
},
{
"label": "Two",
"value": 2
},
{
"label": "Three",
"value": 3
}
]
这是过滤器:
http.get('./data.json')
.map(data => data.json())
.filter (
(x,index) => return x[index].value === 2
)
.subscribe(data => this.d = data);
我想得到结果:
{
"label": "Two",
"value": 2
}
也许我停电了,哪里出错了?
【问题讨论】:
-
尝试控制台登录过滤器只是为了检查您是否真的收到了