Skip to content
Advertisement

How to show in template property from array of objects

I just try to show the value of a property in the template. But at the moment nothing is shown.

So this is the component:

JavaScript

And this is the template:

JavaScript

So I just want to show in the template the value of key. And the console.log returns this:

JavaScript

So I don’t get any errors. But also nothing is shown.

Advertisement

Answer

Two things:

  1. You aren’t returning anything from the map. So undefined would be emitted to the subscription. Use tap for side-effects instead.
  2. You aren’t assigning the response to this.sensorStatusCollection in the subscription.
JavaScript

Update: Type

  1. As pointed out by @TotallyNewb in the comments, the type of this.sensorStatusCollection needs to be an array of type SensorStatusDto
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement