When it comes to styling, inline styles take precedence over css classes.
If you find that adding !important
to your class is necessary for the desired effect, go ahead and do so. However, I recommend avoiding inline styles altogether and utilizing ng-class
instead.
Feel free to check out the demo below or visit this fiddle.
angular.module('demoApp', [])
.controller('mainController', MainController);
function MainController() {
var vm = this;
angular.extend(vm, {
myVar: true,
users2: 1
});
}
.test2 {
color: red !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="demoApp" ng-controller="mainController as ctrl">
<input ng-model="ctrl.users2"/>
<span ng-hide="!ctrl.myVar" style="font-size:28px; color:purple" ng-class="{'test2': ctrl.users2 > 0}">
some content
</span>
</div>