thomas-barthelemy / electron-angular-boilerplate

An Electron + AngularJS + Angular Material boilerplate with native menu and automated build using Electron-packager
MIT License
32 stars 8 forks source link

How to change theme? #4

Open herlon214 opened 7 years ago

herlon214 commented 7 years ago

I've tried:

// app.js

(function () {
    'use strict';

    var app = angular.module(
        'app',
        [
            'ngRoute',
            'ngMaterial',
            'ngAnimate'
        ]
    );
    app.config(
        [
            '$routeProvider',
            function ($routeProvider) {
                $routeProvider.when(
                    '/', {
                        templateUrl: './scripts/home/home.html'

                    }
                );
                $routeProvider.otherwise({redirectTo: '/'});
            },
            '$mdThemingProvider',
            function ($mdThemingProvider) {
              $mdThemingProvider.theme('default').dark();
            }
        ]
    );
})();

But shows:

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=app&p1=Error%3A%20%…n-angular-boilerplate%2Fnode_modules%2Fangular%2Fangular.min.js%3A21%3A332)
jerodfritz commented 7 years ago

In app.js add an additional config and create a new theme then set it as your default like this:

(function() {
  'use strict';

  var app = angular.module('app', ['ngRoute', 'ngMaterial', 'ngAnimate']);
  app.config([
    '$routeProvider',
    function($routeProvider) {
      $routeProvider.when('/', {templateUrl: './scripts/home/home.html'});
      $routeProvider.otherwise({redirectTo: '/'});
    }
  ]).config(function($mdThemingProvider) {
    $mdThemingProvider.theme('myTheme').primaryPalette('red');
    $mdThemingProvider.setDefaultTheme('myTheme');
  });

})();