gpt4 book ai didi

javascript - 如何在 Angular 7 http get api 调用中迭代动态响应

转载 作者:行者123 更新时间:2023-12-02 22:46:33 25 4
gpt4 key购买 nike

我从 angular7 http get 方法获得动态响应,该响应只是一个对象数组,它每分钟都会动态变化,我需要捕获和迭代数组对象的新记录和现有记录,任何人都可以指导我如何解决这个问题

下面添加的数组对象它将每分钟动态更改,我如何迭代新的和现有的记录

------------------------------------------------------------
[
{
"2018": {
"score": "0.03726378083229065",
"TxnNo": "2293760_1-2019r",
"month_interest_std": "23.632556357702818",
"m4_last_payment_amount": "1031.94",
"firstInstalmentDate": "2/28/2018",
"m6_balance": "15044.57",
"m2_m1_balance": "0.06796083071380637",
"period_max": "24.0",
"paymentmethod_nan": "0"
}
}
]
-------------------------------------------------------------------

最佳答案

如果您想保留数组中的新数据和现有数据,最好将其存储在局部变量中的某个位置并对其进行迭代。

每当新数据到来时,将新数据推送到现有数组中,如下所示 -

fullData: Array<any> = [];

this.fullData.push({
"2018": {
"score": "0.03726378083229065",
"TxnNo": "2293760_1-2019r",
"month_interest_std": "23.632556357702818",
"m4_last_payment_amount": "1031.94",
"firstInstalmentDate": "2/28/2018",
"m6_balance": "15044.57",
"m2_m1_balance": "0.06796083071380637",
"period_max": "24.0",
"paymentmethod_nan": "0"
})

<div *ngFor='let item of fullData'>{{item?.TxnNo}}</div>

关于javascript - 如何在 Angular 7 http get api 调用中迭代动态响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58381552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com