我有一些常量数组值,我在订阅中有响应值,我想检查常量数组值是否可用作为响应。我不知道如何在订阅中使用map和filter。如果值可用,那么checkval应该返回true,否则返回value。我可以使用某些函数执行did,但这里我需要使用rxjs运算符
Response:
{
"testLoad": 1603367083993,
"checkData": "test1"
"type": "flag",
"title": "TestFlag",
"styleId": "test",
"BodyContent": {
"properties": "undefined"
}
}
const styleid: Array<string> = ['test1','test2','test3'];
public checkVal(){
this.idVal =this.data.getresponse().subscribe((response => console.log(response ));
}由于我是angular rxjs的新手,你能指导我并帮助解决这个问题吗?
发布于 2020-10-22 20:03:49
根据我所理解的注释,如果response.checkData值包含在pageUid数组中,那么您希望返回一个true可观察值。
您可以执行以下操作:
this.data.getresponse().pipe(
map(response => pageUid.includes(response.checkData)),
).subscribe(checkResult => console.log(checkResult));https://stackoverflow.com/questions/64481273
复制相似问题