【问题标题】:Angular.js, ng-style and IE8Angular.js、ng 风格和 IE8
【发布时间】:2012-11-06 17:28:17
【问题描述】:

我正在使用 angular.js 来重复一些数据。绑定之一计算 x 和 y 坐标并使用 ng-style-binding 设置它们。这在除 IE8 之外的所有浏览器中都可以正常工作。在 IE8 中,它甚至似乎都没有运行我的功能。

但是如果我使用 {{ }} 绑定作为文本输出它会正确输出,但使用属性时则不会。

我的 html 看起来像这样:

<span ng-repeat="obj in item.products" class="product-point" ng-style="getPos(obj.point.x, obj.point.y, index)">
    <img ng-src="Images/add-button.png" width="100%" ng-click="addItemToList(obj.id)"/>
</span>

getPos 函数如下所示:

$scope.getPos=function(x, y) {
    x = (parseFloat(x) * 0.01) * imageSize.width;
    y = (parseFloat(y) * 0.01) * imageSize.height;

    return "left:"+Math.round(x)+"px; " +"top:"+Math.round(y)+"px";
} 

有什么想法吗?

【问题讨论】:

    标签: css internet-explorer-8 angularjs


    【解决方案1】:

    如果您返回 object { top: y, left: x } 而不是字符串,似乎可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-06
      • 2014-02-16
      • 2016-02-05
      • 2013-12-06
      • 2021-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多