AngularJS UI-Router。未知的提供商

时间:2014-09-02 14:20:57

标签: angularjs angular-ui-router mean.io

我收到此错误,但不知道在何处或如何找到并修复它。

我尝试过各种各样的事情,但是没有一件事有效。

我的模块在这里定义:

'use strict';

// create the module
angular.module('mean.dashboard', ['ui.bootstrap', 'xeditable', 'ui.router']);

angular.module('mean.dashboard').run(function(editableOptions) {
  editableOptions.theme = 'bs3'; // bootstrap3 theme. Can be also 'bs2', 'default'
});

这是我的路线的副本:

'use strict';

angular.module('mean.dashboard')

.config(['$stateProvider',
  function($stateProvider) {
    $stateProvider.state('dashboard', {
      url: '/dashboard',
      templateUrl: 'dashboard/views/index.html',
      controller: 'DashboardController'
    });
  }
]);

控制器是:

'use strict';

angular.module('mean.dashboard')

.controller('DashboardController', ['$scope', '$http', 'Global', 'Dashboard',
  function($scope, $http, Global, Dashboard) {


    // Constants and globals

    $scope.global = Global;
    $scope.package = {
      name: 'dashboard'
    };

    ...

Chrome的错误如下。你知道为什么吗?

谢谢!

Error: [$injector:unpr] Unknown provider: DashboardProvider <- Dashboard
http://errors.angularjs.org/1.2.23/$injector/unpr?p0=DashboardProvider%20%3C-%20Dashboard
    at http://localhost:3000/bower_components/angular/angular.js:78:12
    at http://localhost:3000/bower_components/angular/angular.js:3802:19
    at Object.getService [as get] (http://localhost:3000/bower_components/angular/angular.js:3930:39)
    at http://localhost:3000/bower_components/angular/angular.js:3807:45
    at getService (http://localhost:3000/bower_components/angular/angular.js:3930:39)
    at invoke (http://localhost:3000/bower_components/angular/angular.js:3957:13)
    at Object.instantiate (http://localhost:3000/bower_components/angular/angular.js:3977:23)
    at http://localhost:3000/bower_components/angular/angular.js:7274:28
    at http://localhost:3000/bower_components/angular/angular.js:6663:34
    at forEach (http://localhost:3000/bower_components/angular/angular.js:332:20) <section data-ui-view="" class="ng-scope"> angular.js:10061

(anonymous function) angular.js:10061
(anonymous function) angular.js:7357nodeLinkFn angular.js:6707
compositeLinkFn angular.js:6098publicLinkFn angular.js:5994
updateView angular-ui-router.js:2733
(anonymous function) angular-ui-router.js:2697
Scope.$broadcast angular.js:12952
$state.transition.resolved.then.$state.transition angular-ui-router.js:2114
wrappedCallback angular.js:11561
(anonymous function) angular.js:11647
Scope.$eval angular.js:12673
Scope.$digest angular.js:12485
Scope.$apply angular.js:12777
done angular.js:8371
completeRequest angular.js:8585
xhr.onreadystatechange angular.js:8524

1 个答案:

答案 0 :(得分:5)

从依赖项中删除仪表板。 Angular没有找到Dashboard。

.controller('DashboardController', ['$scope', '$http', 'Global',
      function($scope, $http, Global) {