【发布时间】:2022-11-27 22:50:32
【问题描述】:
我从服务器返回了这个对象数组
{
"Code": 200,
"Message": "Success",
"response": [
{
"UserId": null,
"FullName": test,
"Status": null,
"IsActive": 1
},
{
"UserId": null,
"FullName": null,
"Status": 'Active',
"IsActive": 0
}...
...
]
}
在List变量中得到响应
this.Service.getUser(payload).subscribe(result => {
this.List = result['response'];
});
我需要一些方法来操纵 Status 值,例如 Status 是 null 并为其分配 Active 值。
并再次将其存储在 this.List 变量中,而不使用任何循环。
请提出一些解决方案。
谢谢
【问题讨论】:
-
我想知道你怎么能解决这个问题不使用任何循环.您必须遍历
response数组。 -
@DecPK 是否有任何函数可以解决这个问题,或者我们可以在不影响性能的情况下使用循环
标签: javascript angular typescript