Angular 1.2.26"错误:[$ injector:unpr]"

时间:2014-12-11 10:18:39

标签: angularjs

我尝试重现这个理想的样本:http://plnkr.co/edit/L0dRPQyYR3gHho3q6wEc?p=preview

不幸的是,我总是遇到与模态控制器相关的同类问题

这是主控制器:

    inscrit.controller('InscriptionCtrl', [
    '$scope',
    '$log',
    'InscritServices',
    '$rootScope',
    '$modal',
    InscriptionCtrl
]);
function InscriptionCtrl ($scope, $log, InscritServices,$rootScope, $modal) {

    $rootScope.selectedFormations = ['test', 'item2', 'item3'];
    $scope.subcategory = [];
   // $rootScope.lesFormations = InscritServices.getListForm();
    $scope.newInscrit = InscritServices.initIns();


     $scope.open = function (selform) {

        var modalInstance = $modal.open({
            templateUrl: 'views/partials/participant/inscrit/modal.listform.html',
            controller: ModalInstanceCtrl,
            resolve: {
                item: function () {
                    return selform;
                }
            }
        });
    };
};

这是我的模态控制器:

    inscrit.controller('ModalInstanceCtrl', [
    '$scope',
    '$log',
    'InscritServices',
    'item',
    ModalInstanceCtrl
]);

function ModalInstanceCtrl($scope, $log, InscritServices, item) {

   // $log("les formations : " + $scope.lesFormations);
    // $log("items : " + item);
    $scope.selectedFormations= item;
   // $log("avant appel ListForm");
    $scope.lesFormations=InscritServices.getListForm();
   // $log("apres appel ListForm");
    $scope.toggleCheck = function (formation) {
        $log("les formations : " + formation);
        if ($scope.selectedFormations.indexOf(formation) === -1) {
            $scope.selectedFormations.push(formation);
        } else {
            $scope.selectedFormations.splice($scope.selectedFormations.indexOf(formation), 1);
        }

        //$log.info("formation sél : " + formation.libForm);
        $log.info("formation sél : " + $scope.selectedFormations);
    };

    $scope.ok = function () {
        // $rootScope.selectedFormations = $scope.selectedFormations;
        $log.info("scope - formation sél : " + $scope.selectedFormations);
        $scope.subcategory = [];
        for(var i = 0; i < $scope.selectedFormations.length; i++) {
            $scope.subcategory.push({form: $scope.selectedFormations[i], term: "---", credit: "---", grade: "---"});
           // $log("valeur sél " + $scope.subcategory)
        }
        $scope.$close(true);
    };

    // fermeture fenêtre sans maj
    $scope.close = function () {
        $scope.$close(true);
    };

};

当我点击我的按钮时,我收到了关于项目提供者的消息:

&#34;错误:[$ injector:unpr] http://errors.angularjs.org/1.2.26/ $ injector / unpr?p0 = itemProvider%20%3C-NaNtem&#34;

此外,当我想在这样的模态控制器中使用$ log时:

    inscrit.controller('ModalInstanceCtrl', [
    '$scope',
    '$log',
    'InscritServices',
    'item',
    ModalInstanceCtrl
]);

function ModalInstanceCtrl($scope, $log, InscritServices, item) {

    $log("this is a test")
 ...

我收到消息:

&#34; TypeError:object不是函数&#34;

谁能帮帮我?

0 个答案:

没有答案