javascript - AngularJS: How to set a variable inside of a template? -


how can avoid having {{f = ...}} statement in third line print out content of forecast[day.iso]?

i want avoid using forecast[day.iso].temperature , on every iteration.

<div ng-repeat="day in forecast_days">   {{$index}} - {{day.iso}} - {{day.name}}   {{f = forecast[day.iso]}}   temperature: {{f.temperature}}<br>   humidity: {{f.humidity}}<br>   ... </div> 

use nginit: http://docs.angularjs.org/api/ng.directive:nginit

<div ng-repeat="day in forecast_days" ng-init="f = forecast[day.iso]">   {{$index}} - {{day.iso}} - {{day.name}}   temperature: {{f.temperature}}<br>   humidity: {{f.humidity}}<br>   ... </div> 

example: http://jsfiddle.net/coma/uv4qf/


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -