【发布时间】:2019-06-10 07:38:13
【问题描述】:
如何通过过滤对象内部的键值来获取对象?我有下面的对象,我只需要提取具有 session_id:23 的数据
数据 = [{ name: "拳名", session_id:“23”, 登录:“日期” }, { name: "第二个名字", session_id:“18”, 登录:“日期” }, { name: "第三个名字", session_id:“23”, 登录:“日期” }];
I tried Angular Filter and Map method to filter this out but dosent seem to work for me here.
.pipe(
map((res) => {
res => res.filter(res => res.season_id == 23)
console.log(res);
})
)
ngOnInit() {
this._service.getData();
this._service.updatedPlayer
.pipe(
map((res) => {
res => ress.filter(res => res.season_id == 23)
console.log(res);
})
)
.subscribe(
(playerSession) => {
this.playerSessionUpdate = playerSession;
}
)
}
【问题讨论】:
标签: javascript html json angular angular6