如何设置一个变量的模板里面?

编程入门 行业动态 更新时间:2024-10-11 11:21:47
本文介绍了如何设置一个变量的模板里面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我怎样才能避免在 {{F = ...}} 第三行语句打印出的预测内容[天.ISO] ?

我要避免使用预测[day.iso] .temperature 等为每次迭代。

< D​​IV NG重复=天forecast_days>  {{$指数}} - {{day.iso}} - {{day.name}}  {{F =预测[day.iso]}}  温度:{{f.temperature}}< BR>  湿度:{{f.humidity}}< BR>  ...< / DIV>

解决方案

使用 ngInit :docs.angularjs/api/ng.directive:ngInit

< D​​IV 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/

更多推荐

如何设置一个变量的模板里面?

本文发布于:2023-11-24 11:47:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1625077.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   如何设置   模板

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!