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

后端 未结 2 944
庸人自扰
庸人自扰 2021-01-30 10:05

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 fore

2条回答
  •  日久生厌
    2021-01-30 10:22

    Use ngInit: https://docs.angularjs.org/api/ng/directive/ngInit

    {{$index}} - {{day.iso}} - {{day.name}} Temperature: {{f.temperature}}
    Humidity: {{f.humidity}}
    ...

    Example: http://jsfiddle.net/coma/UV4qF/

提交回复
热议问题