重复的使用
Using ng-repeat
我正在尝试使用 ng-repeat 来显示所有 threeDay.forecast.simpleforecast.forecastday.high.fahrenheit
的,因为 forecastday
是一个数组。在这种情况下我将如何使用 ng-repeat
?这是我的代码,仅显示 forecastday 数组中第一条数据的华氏度值。
<body ng-app="ForecastApp">
<div class="main" ng-controller="MainController">
<p>{{ threeDay.forecast.simpleforecast.forecastday[0].high.fahrenheit }}</p>
</div>
</body>
您可以在您的情况下像这样使用 ng-repeat:
<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>
只需遍历所有 threeDay.forecast.simpleforecast.forecastday table 并显示其中的每个 high.fahrenheit 元素。
假设 threeDay.forecast.simpleforecast.forecastda
是一个 collection/array 并且该数组中的每个项目都有一个 high
属性,它又有一个 fahrenheit
属性
<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>
我正在尝试使用 ng-repeat 来显示所有 threeDay.forecast.simpleforecast.forecastday.high.fahrenheit
的,因为 forecastday
是一个数组。在这种情况下我将如何使用 ng-repeat
?这是我的代码,仅显示 forecastday 数组中第一条数据的华氏度值。
<body ng-app="ForecastApp">
<div class="main" ng-controller="MainController">
<p>{{ threeDay.forecast.simpleforecast.forecastday[0].high.fahrenheit }}</p>
</div>
</body>
您可以在您的情况下像这样使用 ng-repeat:
<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>
只需遍历所有 threeDay.forecast.simpleforecast.forecastday table 并显示其中的每个 high.fahrenheit 元素。
假设 threeDay.forecast.simpleforecast.forecastda
是一个 collection/array 并且该数组中的每个项目都有一个 high
属性,它又有一个 fahrenheit
属性
<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>