所以我基本上有一个带有样式属性的div块,其中我已离开:{{left}} px;右:{{right}} px。
$ scope.left和$ scope.right得到更新,但不会移动我的项目。
这是一个小提琴
http://jsfiddle.net/climboid/5XqG7/4/
任何帮助都非常感谢
<div ng-app ng-controller="Controller" class="container">
<button class="moveTo" ng-click="findPosClick()"> move to here</button>
<div class="block" style="left:{{left}}px; top:{{top}}px;"></div>
<div class="posTxt">left:{{left}}</div>
<div class="posTxt2">top:{{top}}</div>
</div>
function Controller($scope) {
$scope.findPosClick = function(){
var location = event.target ? event.target : event.srcElement;
var pos = $(location).position();
$scope.left = pos.left;
$scope.top = pos.top;
}
}
当我查看ie9控制台时,我没有看到将样式属性应用于div ......
答案 0 :(得分:8)
这是IE的一个已知问题;它只会抛弃它不喜欢的样式标签。
改为使用ng-style
指令。
<div ng-style="{left: left+'px', top: top+'px'}"></div>
答案 1 :(得分:0)
style
属性未解析角度表达式({{}})。因此,您应该在角度应用中使用ng-style
而不是style
。