【问题标题】:Background image spinner when not loaded未加载时的背景图像微调器
【发布时间】:2015-04-26 22:31:21
【问题描述】:

使用div 和

<div ng-style="{'background-image':'url('+image+')'}"></div>

我想在背景图像尚未完全加载时在div 中显示一个微调器。这怎么可能?我想使用background-image 来显示图像(而不是src),因为我想crop and center 我的图像。

【问题讨论】:

  • 你有没有找到任何方法来添加微调器?

标签: javascript css angularjs image angularjs-directive


【解决方案1】:

在加载时将作用域上的“加载”变量设置为 true,然后在加载时设置为 false。

在“加载”时使用模板中的 ng-class 设置具有背景图像的类,例如ng-class="{'loading-class': loading} "

使用 onloadeddata 事件Angular on video load event

【讨论】:

  • 感谢您的回答。您能否在答案中添加我将如何检测背景图像是否正在加载?
  • 背景图片没有加载事件?
  • 图片添加到$templateCache怎么样?
猜你喜欢
  • 2014-02-17
  • 2018-02-04
  • 1970-01-01
  • 1970-01-01
  • 2014-06-14
  • 2021-03-31
  • 2017-05-01
  • 1970-01-01
相关资源
最近更新 更多