another injector issue

what is wrong with this dependency injection? Every time I inject modalController into... well, anything... I get an injector error. Ive included the js file as a script reference, and Ive referenced my modal module. Here is the actual error:

Error: [$injector:unpr] http://errors.angularjs.org/1.3.0-beta.13/$injector/unpr?p0=modalControllerProvider%20%3C-%20modalController

personnelModule.controller('PersonnelController', ['$scope', 'personnelFactory','modalController', function($scope, personnelFactory, modalController){
    personnelFactory.getPersonnel().then(function(personnel){
        $scope.personnel = personnel;
        $scope.events = {};
        $scope.events.addPerson = function() {
            $modal.open({
              templateUrl: '../SiteAssets/views/ModalTemplate.html',
              controller: modalController
            });
        };
    });
}]);

modalModule.controller('modalController', ['$scope', '$modalInstance', function($scope, $modalInstance){
      $scope.ok = function () {
        alert('ok clicked');
        $modalInstance.dismiss('canceled'); 
      };
      $scope.cancel = function () {
        alert('cancel clicked');
        $modalInstance.dismiss('canceled'); 
      };
}]);

Try referencing the controller as a string. (in the $modal.open)

controller: 'modalController'

EDIT

You also need to inject the $modal service into the 'PersonnelController' and I believe injecting the 'modalController' is unnecessary.

personnelModule.controller('PersonnelController', ['$scope', 'personnelFactory', '$modal', function($scope, personnelFactory, $modal){

EDIT 2

Try this Plunker. The most notable changes I made were removing the

<div ng-controller="modalController"></div>

and

<button ... ng-click="ok()">OK</button>

Do not inject controllers into each other. I mean, why would you want to do that??

链接地址: http://www.djcxy.com/p/77678.html

上一篇: 为什么角度给喷油器模块错误?

下一篇: 另一个注射器问题