【问题标题】:AngularJS not loading css resourcesAngularJS不加载css资源
【发布时间】:2014-05-24 22:57:00
【问题描述】:

在我的具有 ui-router 依赖项的 AngularJS 应用程序中,出于某种原因 - 在 Google Chrome 上 - 我的样式表中的 background-images 没有加载(甚至没有显示在开发工具的网络选项卡中)。

也许是因为我已经将链接 href 绑定到我的范围,并即时更改它?

index.html:

<link rel='stylesheet' ngIf='stylePath' ng-href='{{stylePath}}'>

在我的控制器中,我将$scope.stylePath 设置为'login.css'

如果我打开开发工具并取消选中background-image,然后再次选中它,它会加载图像并正常显示。

在 IE11 上没有问题。

有什么想法吗?

【问题讨论】:

  • 不考虑太多,我会尝试删除 ngIf 并查看是否是导致问题的原因(然后从那里开始工作)。
  • 指令不能包含大写字母,因为 Angular 会将它们转换为小写破折号。 ngIf 例如应该用作 ng-if

标签: angularjs google-chrome resources stylesheet angular-ui-router


【解决方案1】:

更改自:

<link rel='stylesheet' ngIf='stylePath' ng-href='{{stylePath}}'>

收件人:

<link rel='stylesheet' ng-if='stylePath' ng-href='stylePath'>

【讨论】:

    猜你喜欢
    • 2014-02-13
    • 1970-01-01
    • 2012-09-26
    • 2014-10-11
    • 2022-01-21
    • 2014-09-16
    • 1970-01-01
    • 2012-12-22
    • 2017-07-13
    相关资源
    最近更新 更多