本文介绍了如何设置一个变量的模板里面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能避免在 {{F = ...}} 第三行语句打印出的预测内容[天.ISO] ?
我要避免使用预测[day.iso] .temperature 等为每次迭代。
< DIV NG重复=天forecast_days> {{$指数}} - {{day.iso}} - {{day.name}} {{F =预测[day.iso]}} 温度:{{f.temperature}}< BR> 湿度:{{f.humidity}}< BR> ...< / DIV>解决方案
使用 ngInit :docs.angularjs/api/ng.directive:ngInit
< DIV NG重复=天forecast_daysNG-的init =F =预测[day.iso]> {{$指数}} - {{day.iso}} - {{day.name}} 温度:{{f.temperature}}< BR> 湿度:{{f.humidity}}< BR> ...< / DIV>例如: jsfiddle/coma/UV4qF/
How can I avoid having the {{f = ...}} statement in the third line print out the content of forecast[day.iso]?
I want to avoid using forecast[day.iso].temperature and so on for 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: docs.angularjs/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: jsfiddle/coma/UV4qF/
更多推荐
如何设置一个变量的模板里面?
发布评论