Reputation: 863
I want to make an application with dynamic theming. For example, there is a button, you click it and color of some elements changes by some rule. First idea - do it with
<style type="text/css" ng-bind="ownStyle"></style>
and init ownStyle in $rootScope:
$rootScope.ownStyle = "* {color: green }";
But it seems awful + it's too hard to write css rules as string. Is there a more elegancy way to do it?
Upvotes: 1
Views: 1686
Reputation: 56
Can try something like this..
$rootScope.color = red;
$scope.changecolor = function(){
$rootScope.color = blue;
}
/* Base color */
.dinamic{
background-color: white;
}
<style>
.dinamic{
background-color: {{$rootScope.color}} !important;
}
</style>
<button class="dinamic">I Will Change Color</button>
Upvotes: 3
Reputation: 5532
You can use ng-class built in directive.
<div ng-class="{'some-class': condition}></div>
Upvotes: 1