【问题标题】:AngularJS style issue IEAngularJS 样式问题 IE
【发布时间】:2014-10-15 15:51:28
【问题描述】:

我想弄清楚如何在 IE 上进行这项工作:

<div ng-if="result.is_mesurable==true" style="left:{{ (result.user_score * 20)-10}}%" class="test-box">

代码基本生成动态表,对象的左边位置取自user_score值。

我知道 IE 没有正确读取此声明,我过去也遇到过类似的错误:

AngularJS weird render issue

“因为 {{xxx.xxx}} 是无效 css 被 IE 截断,当 Angular 编译器扫描所有属性时,style 属性为空。”

我知道一定有类似的解决方案,但到目前为止我一直无法弄清楚。

提前致谢。

另外,请注意,IE 上的结果是一个空样式 attr。

【问题讨论】:

    标签: css angularjs internet-explorer angularjs-scope ng-style


    【解决方案1】:

    问题是一样的,可以用 ng-style 或 ng-attr-style 解决:

    ng 风格:

    <div ng-style="{left: ((result.user_score * 20) - 10) + '%'}" class="test-box" ng-if="result.is_mesurable==true">
    

    ng-attr-*

    <div ng-attr-style="left:{{ (result.user_score * 20)-10}}%" class="test-box" ng-if="result.is_mesurable==true" >
    

    【讨论】:

    • 太好了,再次感谢。我仍然觉得找出像这样的 Angular + IE 问题非常棘手。
    猜你喜欢
    • 1970-01-01
    • 2011-12-18
    • 2016-08-11
    • 2013-11-25
    • 2018-01-09
    • 2011-05-05
    • 2011-11-14
    • 2015-02-25
    • 2013-01-28
    相关资源
    最近更新 更多