Monday, 8 May 2017

AngularJS Material dark mode switch not changing background

As the title says, I want to implement a darkmode switch in my nodeJS, express and angular project, and it works perfect. But the background isn't changing...

The buttons, toolbar and fonts on them are changing color, but the background stays white which kind off defeats the purpose of a darkmode...

Here is my code to change the theme in the controller

angularApp.controller('global', function($scope) {
    $scope.changeTheme = function(){
        $scope.theme = $scope.darkmode ? 'dark' : 'default';
    }
});

And here is the code of my angularApp

var angularApp = angular.module('app', ['ngMaterial'])
.config(function($mdThemingProvider) {
    $mdThemingProvider.alwaysWatchTheme(true);
..
.. The theming configs ..

And yes, I am calling .dark();.

And finally, here is my switch to change the themes

md-switch(ng-change="changeTheme()" ng-model="darkmode") Darkmode

Its written in Pug because of templating with express

The themes are called default and dark

Any help is appreciated!



via Martijn Vissers

No comments:

Post a Comment