未知提供商:$ mdThemingProvider

时间:2017-03-25 18:11:06

标签: javascript angularjs angular-ui-router angular-material bower

所以,我正在尝试使用angular-material,但当我想注入$ mdThemingProvider时,我收到此错误:Unknown provider: $mdThemingProvider

如果我删除$mdThemingProvider角质材料样式不起作用。

我的模块:

    angular.module('bookStoreApp', ['ngAnimate', 'ui.router'])
.config([
  '$stateProvider', 
  '$urlRouterProvider', 
  '$mdThemingProvider',
  function($stateProvider, $urlRouterProvider, $mdThemingProvider) {
    $mdThemingProvider.theme('default')
    .primaryPalette('blue')
    .accentPalette('red');

    $urlRouterProvider.otherwise('/');

    $stateProvider// home page
    .state('/', {
      url: '/',
      templateUrl: 'views/home.html',
      controller: 'BookControllers'
    });
  }
  ]);

我的推荐信:

    <link rel="stylesheet" href="libs/angular-material/angular-material.min.css">
  <script src="libs/angular/angular.min.js"></script>
  <script src="libs/angular-animate/angular-animate.min.js"></script>
  <script src="libs/angular-aria/angular-aria.min.js"></script>
  <script src="libs/angular-messages/angular-messages.min.js"></script>
  <script src="libs/angular-ui-router/release/angular-ui-router.min.js"></script>

我的bower.json依赖项

  "dependencies": {
"angular": "^1.6.3",
"angular-material": "^1.1.3",
"angular-ui-router": "^0.4.2"

}

1 个答案:

答案 0 :(得分:2)

在定义ngMaterial模块时,您需要注入bookStoreApp模块,其中定义了$mdThemingProvider

 angular.module('bookStoreApp', ['ngAnimate', 'ui.router', 'ngMaterial'])

而不是

angular.module('bookStoreApp', ['ngAnimate', 'ui.router'])