I am trying to print a value out of an object that is not array, but have unique key into the object everytime an api throws result below is 2 example :
in json :
1st result search:
terms.357.price = 100
2nd result search:
terms.123.price = 100
this always change per api request.
I cant specify in the html like :
{{ term.123.price }}
but it should be :
{{ term.[key].price }}
is there anyway we can do this?
as I tried using the ngFor it is not available to not an array???
I suggest thinking backwards. If your template wants to be displaying a repeated bunch of markup for each of several elements, then turn whatever you are getting from this API into an array.
every search will popup json array nested with that particular data that I need to access, but its having a unique number each search, making it hard to retrieve
I mean transform the value in your service that interacts with the API. My primary point is that I would write the template the easiest way to write the template, and then backfill the data to match that, instead of doing the hard work in the template.
No, not necessarily. I never interact directly with HttpClient in pages. I always write injectable services that do that, and in that service is where I would do this data massaging. What comes out of the service should be an Observable<Foo[]> or Observable<Foo> or whatever makes the template easiest to write.