0

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"
      }
    }
  ]
-------------------------------------------------------------------
1
  • 1
    Can you provide some details on what you are wanting to do when iterating? If the keys of the objects in the array is what is changing, you can use Object.keys(obj) to get a list of the keys in the object which you can then loop over. Commented Oct 14, 2019 at 17:43

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.