0

Having an interesting time pulling this weather_code object to the page. Any ideas? :-)

enter image description here

Here's my code:

    <div *ngFor="let forecast of this.weatherData?.forecasts | keyvalue">
    {{ forecast.value.hourly[0].weather_code }}
    </div>
4
  • 1
    Please add the desired behavior, the error code if there's any and the typescript code. Commented Jan 25, 2021 at 19:21
  • 1
    Hourly is another array so if you need all those values, you can do another *ngFor.. Commented Jan 25, 2021 at 19:24
  • 1
    @JFPicard - I simply want to display weather_code on the page. No error. Just the call being logged in Console. Commented Jan 25, 2021 at 19:29
  • just a friendly reminder; in your html you don't have to and shouldn't use this. instead of this.weatherData?.forecasts you can just write weatherData?.forecasts Commented Jan 31, 2021 at 17:26

2 Answers 2

2

where is the forecasts array? If the whole object is the displayed object (in your screenshot) you just have to do response.forecast['2021-01-25'].hourly[0].weather_code

Sign up to request clarification or add additional context in comments.

5 Comments

what is array you're trying to iterate. Because in your screenshot there isn't an iterable (array) called forecasts ?
Trying to go after the Forecast>date>hourly>weather_code
well, I feel dumb. changed "forecasts" to "forecast" and it works. here is a working snippet: {{ forecast.value.hourly[0].weather_code }}
question: how do you pull the second item under the forecast array without defining a specific value? These are not working... '{{ forecast.value[1].hourly[0].weather_code }}' '{{ forecast[1].hourly[0].weather_code }}'
forecast[value].hourly[0].weather_code @Devvvvv
0

{{ forecast.value.hourly[0].weather_code }}

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.