-
Notifications
You must be signed in to change notification settings - Fork 27.5k
ngStyle fails when use !important #5379
Comments
You're not able to use the So, there are some work arounds here: <ANY data-ng-attr-style="{{ blue && 'background-color: blue!important' || '' }}">
</ANY> This would be your best way to go in terms of browser-support, because the CSS property priority will get parsed correctly here. Alternatively, you can also do the following in javascript: $scope.$watch(conditionalStyle);
function conditionalStyle() {
if ($scope.blue) {
$element[0].style.setProprety('background-color', 'blue', 'important');
} else {
$element[0].style.backgroundColor = '';
}
} Where $element is a jquery/jqLite object referencing an HTMLElement. caveats: Not supported in IE < 9. So, workaround #1 is probably your best bet for this behaviour where you depend on property priority... original answer here In any case, inline styles tend to take precedence over those found in stylesheets, except for those with '!important' If you really need this, you can use ng-attr-style to do it, at least in chrome/ff28. http://plnkr.co/edit/drS4oqb09gOIJeXjCfJo?p=preview I suppose jqLite could be hacked to use |
Thanks for your answer. I will do tests with style and !important. I will report-it here soon. |
If it helps, according to http://help.dottoro.com/ljdpsdnb.php, IE8 and less don't provide the |
Thanks for your comprehensive answer @caitp. It helps a lot. I will close this issue. Maybe I will open-it back for Angular 2.0, when IE8 will be no longuer supported. |
jqLite .css() function has problems with `!important`. See e.g.: angular/angular.js#5379
Tested with angular 1.2.4
Example : http://jsfiddle.net/yappli/X8era/4/
The text was updated successfully, but these errors were encountered: