基本上我有一个div,我正在设置一个动态的风格
<div style="position:relative; left: {{et.getNumPadStyle()}}px">
我的功能getNumPadStyle
将有
function getNumPadStyle {
var num = "25";
return num;
}
这给了我一个错误
Referencing DOM nodes in Angular expressions is disallowed! Expression: et.getNumPadStyle()
当我检查元素时,确切的数字没有反映
element {
position:relative;
left:{{et.getNumPadStyle()}}px
}
如何解决这个问题?
答案 0 :(得分:3)
您的角度函数必须在范围内并使用$ scope.getNumPadStyle()
调用 $scope.getNumPadStyle = function ()
{
var num = "25";
return num;
}
答案 1 :(得分:2)
您的代码中存在少量错误。找到下面的代码示例
Html:
function TodoCtrl($scope) {
$scope.getNumPadStyle= function() {
var num = "455";
return num;
}
};
JS:
UIView.animate(withDuration: 0.2, animations: {
cell?.frame = CGRect(x: (cell?.frame.origin.x)!-15, y: (cell?.frame.origin.y)!, width: cell!.bounds.size.width, height: cell!.bounds.size.height)
}) { (finished) in
UIView.animate(withDuration: 0.3, animations: {
cell?.frame = CGRect(x: (cell?.frame.origin.x)!+15, y: (cell?.frame.origin.y)!, width: cell!.bounds.size.width, height: cell!.bounds.size.height)
})
tableView.deselectRow(at: indexPath, animated: true)
}
答案 2 :(得分:1)
尝试AxisX and AxisY
这样:
ng-style
在Angular代码中:
<div ng-style="et.getNumPadStyle()">