I'd like to get access to the current element css properties when I use ng-style
Since the following element:
<div ng-style="changeWidth()">
Get access to its CSS properties
$scope.changeWidth = function(element) {
return {
width: element.width() / 2
}
};
Someone knows the best way to achieve that?
Use directives:
.directive("getStyle",function(){
return{
link:function(scope,element){
element[0].style.border = "5px dotted #090";
}
}
});
Example: http://plnkr.co/edit/izOrEi?p=preview
One more (directive-scope interaction): http://plnkr.co/edit/uL7N1j?p=preview
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With