简体   繁体   中英

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

below added array object it will change every minute dynamically how can i iterate new and existing records

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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