Is there a way to dynamically change the style of a webpage based on user selection using CSS in AngularJS?
I've searched online, but haven't found a solution that works for me.
I have a CSS file with different styles and I want to apply these styles to various divs by changing background color, text color, and font style as needed.
$scope.model.webPageSkin = 'Default';
// create a list of themes
$scope.bootstraps = [
{ name: 'Plain', url: 'Plain' },
{ name: 'Blue', url: 'Blue' },
{ name: 'Green', url: 'Green' } ,
{ name: 'Default', url: 'default' } ,
];
**Plain.css**
.ChangeColor
{
font-family: "Source Sans Pro",Calibri,Candara,Arial,sans-serif;
font-size: 15px;
line-height: 1.42857143;
color: #333333;
background-color: #ddd;
}
**default.css**
.ChangeColor
{
font-family: "Source Sans Pro",Calibri,Candara,Arial,sans-serif;
font-size: 15px;
line-height: 1.42857143;
color: #333333;
background-color: #3c8dbc;
}
<div class="wrapper>
<header class="main-header">
<nav class="navbar navbar-static-top" ng-class="{ChangeColor:
model.webPageSkin !important;}">
</nav>
</header>
<div class="row">
<select ng-model="model.webPageSkin" ng-options="bootstrap.url as bootstrap.name for bootstrap in bootstraps">
</select>
</div>
</div>
Any suggestions on how to achieve this dynamic style switching are welcome!