2012-11-18 4 views
0

일부 데이터를 반복하려면 angular.js를 사용하고 있습니다. 바인딩 중 하나는 x 및 y 좌표를 계산하고이를 ng-style-binding으로 설정합니다. IE8을 제외한 모든 브라우저에서 정상적으로 작동합니다. IE8에서는 제 기능을 수행하지 않는 것 같습니다.Angular.js, ng-style 및 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"; 
} 

어떤 아이디어?

답변

2

문자열 대신 object { top: y, left: x }을 반환하면 제대로 작동합니다.