简体   繁体   English

如何在 angular 7 http 中迭代动态响应得到 api 调用

[英]how to iterate dynamic response in angular 7 http get api call

i am getting dynamic response from angular7 http get method, the response is only one array of object and it will change every minute dynamically, i need to capture and iterate new and existing records of array object can any one guide me how to solve this我从 angular7 http get 方法得到动态响应,响应只是 object 的一个数组,它会每分钟动态变化,我需要捕获和迭代数组 ZA8CFDE6331BD59EB2AC96F8911C4B6 的新记录和现有记录

below added array object it will change every minute dynamically how can i iterate new and existing records下面添加了数组 object 它会每分钟动态变化我如何迭代新的和现有的记录

------------------------------------------------------------
[
    {
      "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"
      }
    }
  ]
-------------------------------------------------------------------

If you want to keep both new and existing data from array, better you can store it somewhere in the local variable and iterate over it.如果要保留数组中的新数据和现有数据,最好将其存储在局部变量中的某个位置并对其进行迭代。

whenever new data comes push new data into existing array, like below -每当新数据出现时,将新数据推送到现有数组中,如下所示 -

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM