Css 样式ie9内的angularjs评估范围不工作
所以我基本上有一个带有style属性的div块,在它里面我留下了:{{left}}px;右:{right}}px。Css 样式ie9内的angularjs评估范围不工作,css,angularjs,internet-explorer-9,Css,Angularjs,Internet Explorer 9,所以我基本上有一个带有style属性的div块,在它里面我留下了:{{left}}px;右:{right}}px。$scope.left和$scope.right得到更新,但这不会移动我的项目。 这里有一把小提琴非常感谢您的帮助 <div ng-app ng-controller="Controller" class="container"> <button class="moveTo" ng-click="findPosClick()"> move to here
$scope.left和$scope.right得到更新,但这不会移动我的项目。
这里有一把小提琴
非常感谢您的帮助
<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;
}
}
搬到这里来
左:{{left}}
top:{{top}}
功能控制器($scope){
$scope.findPosClick=function(){
var location=event.target?event.target:event.src元素;
var pos=$(位置).position();
$scope.left=位置左侧;
$scope.top=pos.top;
}
}
另外,当我查看ie9控制台时,我根本没有看到应用于div的style属性。这是IE的一个已知问题;它只会抛出它不喜欢的样式标签 改用
ng style
指令
style
属性未解析为角度表达式({{})。因此,在角度应用程序中应该使用ng style
而不是style
。是的,谢谢Andy!