1

I have been working with angularjs material now and I want to add scope inside of config file module. When I insert the scope it gives me error. Is there way can I add scope element like this.

app.config(function($mdThemingProvider, $scope) {
    $scope.color = 'red'
    $mdThemingProvider.theme('default')
        .primaryPalette($scope.color)
};

I tried $provider method but i could not. Could you help me

Lupin
  • 1,225
  • 11
  • 17
Shaxrillo
  • 769
  • 1
  • 7
  • 24
  • Scope corresponds to an html view. Only angular controllers and directives can have the $scope access. Because, it simply does not make sense, what scope do you intend to give to the config? Scopes are with respect do html DOM and only controllers or directives have access to the respective scopes. – manasi sakhare Apr 28 '15 at 08:33
  • You can not ask for $scope during configuration phase. Not even $rootScope. Config is the phase that alters provider configuration. – cleftheris Apr 28 '15 at 08:33
  • 1
    I guess this is the wrong way to do it. There is no scope available in the 'config' lifecycle. A $scope is bound to a controller or a directive. If you wanna initialize some objects you could use app.run(function($rootScope){...}) – Michael Apr 28 '15 at 08:33
  • possible duplicate of [Cannot get to $rootScope](http://stackoverflow.com/questions/10486769/cannot-get-to-rootscope) – cleftheris Apr 28 '15 at 08:34
  • it will not working with run module I tried ... – Shaxrillo Apr 28 '15 at 08:36
  • it gives me injector error – Shaxrillo Apr 28 '15 at 08:36
  • https://material.angularjs.org/#/Theming/03_configuring_a_theme it only configuring with config module – Shaxrillo Apr 28 '15 at 08:37

0 Answers0