I have two CSS file generated, One for lighter Version and other for darker Version. So please let me know how can i maintain two theme for same App?
Any idea how can we implement it on ionic app using theme toggled?
I have two CSS file generated, One for lighter Version and other for darker Version. So please let me know how can i maintain two theme for same App?
Any idea how can we implement it on ionic app using theme toggled?
Working plunker
You can easily toggle between CSS files.
index.html:
set your ng-app
on the HTML
tag:
<html ng-app="starter">
dynamically set your style:
<link ng-href="{{style}}" rel="stylesheet">
app.js: define your default style in run
:
$rootScope.style = "css/style.css";
controllers.js: add your toggle style logic:
//All available styles
$scope.styles = [
{
name: "Default",
url: "style.css"
},
{
name: "Dark",
url: "dark-style.css"
}
];
/**
* Change the style.
* @param style The selected style.
*/
$scope.changeStyle = function(style){
$rootScope.style = "css/" + style.url;
};
view.html: attach the related HTML
:
<label class="item item-input item-select">
<div class="input-label">
Style
</div>
<select ng-options="style as style.name for style in styles" ng-change="changeStyle(style)" ng-model="style">
</select>
</label>