使用ng-style在CSS中动态转换

使用ng-style在CSS中动态转换,第1张

使用ng-style在CSS中动态转换

您不能在属性内的JS字符串内使用大括号绑定。您可以将变量附加到字符串上:

<div ng->{{number}}</div>

另外,我用单打替换了双引号。

但是,您可以考虑向控制器添加函数以返回适当的样式:

控制器:

// Create a variable to store the transform value$scope.transform = "rotate(0deg)";// When the number changes, update the transform string$scope.$watch("number", function(val) {    $scope.transform = "rotate("+val+"deg)";});

HTML:

<!-- We can now use the same value for all vendor prefixes --><div ng->{{number}}</div>

更新的柱塞



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/4957226.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-14
下一篇 2022-11-13

发表评论

登录后才能评论

评论列表(0条)

保存