更新时间:2023-10-19 23:26:16
我最终通过解决这个问题 NG-风格
是这样的:
I ended up solving this problem by using ng-style
like this:
标记:
<div custom-directive ng-style="setWidth()"></div>
角:
link: function(scope, elem, attrs) {
scope.setWidth = function() {
return { "width": "200px" }
}
}
纳克风格预计其中有一个关键的CSS样式名称和值作为相应的样式值的对象。这在所有的浏览器。
ng-style expects an object which has a key as the CSS style name and the value as the value for the corresponding style. This works in all browsers.