Monday, 15 April 2013

Can't change CSS style in AngularJS -



Can't change CSS style in AngularJS -

for reasons, can't alter style of element using next :

angular.element("#element").style.height = 100px;

i'm sure angular.element("#element") works, returns dom element. plus, works :

angular.element("#element").addclass('something');

(everything i've found ngstyle don't think i'm looking ?)

should utilize else ?

if : ? why .style.something doesn't work ?

according the docs:

note: element references in angular wrapped jquery or jqlite; never raw dom references.

so .style property not available directly, since property of wrapped htmlelement.

you can either utilize ivarni's approach hold of htmlelement (angular.element(...)[0].style...) or utilize jquery's/jqlite's .css() method:

angular.element('#element').css('height', '100px');

css angularjs

No comments:

Post a Comment