Reputation:
I'm trying to use ng-repeat to display all the threeDay.forecast.simpleforecast.forecastday.high.fahrenheit
's, because forecastday
is a array. How would I use ng-repeat
in this situation? Here is my code to just display the value of fahrenheit for the first piece of data in the forecastday array.
<body ng-app="ForecastApp">
<div class="main" ng-controller="MainController">
<p>{{ threeDay.forecast.simpleforecast.forecastday[0].high.fahrenheit }}</p>
</div>
</body>
Upvotes: 1
Views: 51
Reputation: 218732
Assuming threeDay.forecast.simpleforecast.forecastda
is a collection/array and each item in that array has a high
property which again has a fahrenheit
property
<body ng-app="ForecastApp">
<div class="main" ng-controller="MainController">
<p ng-repeat="f in threeDay.forecast.simpleforecast.forecastday">
{{f.high.fahrenheit}}
</p>
</div>
</body>
Upvotes: 0
Reputation: 343
You can use ng-repeat like so in your case:
<body ng-app="ForecastApp">
<div class="main" ng-controller="MainController">
<p ng-repeat="forecastday in threeDay.forecast.simpleforecast.forecastday">
{{ forecastday.high.fahrenheit }}
</p>
</div>
</body>
Just loop through all your threeDay.forecast.simpleforecast.forecastday table and show every high.fahrenheit element of it.
Upvotes: 2