2016-07-15 112 views
0

我已經檢查了一些其他類似的錯誤的問題,他們似乎表明,我可以有一個語法錯誤。但是,我已經仔細檢查並刪除了我的代碼,但我不確定有什麼問題。我已經定義了一個註冊控制器,但似乎由於某種原因沒有被識別。Angular - 參數'RegisterController'是不是一個函數,得到undefined

相關的文件應該是register.controller.js文件,該文件是在static/js/myApp.js,這是static。我已經添加了一些其他配置文件的位置上下文:

myApp.js

(function() { 
    'use strict'; 

    angular 
    .module('myApp', [ 
     'myApp.config', 
     'myApp.routes' 
     //'myApp.accounts', 

    ]); 

    angular 
    .module('myApp.config', []); 

    angular 
    .module('myApp.routes', ['ngRoute']); 

    console.log(angular); 
    angular 
    .module('myApp') 
    .run(run); 

    run.$inject = ['$http']; 

    /** 
    * @name run 
    * @desc Update xsrf $http headers to align with Django's defaults 
    */ 
    function run($http) { 
    $http.defaults.xsrfHeaderName = 'X-CSRFToken'; 
    $http.defaults.xsrfCookieName = 'casrftoken'; 
    } 
})(); 

myApp.routes.js

(function() { 
    'use strict'; 

    angular 
     .module('myApp.routes') 
     .config(config); 

    config.$inject = ['$routeProvider']; 

    /** 
    * @name config 
    * @desc Define valid application routes 
    */ 
    function config($routeProvider) { 
     $routeProvider.when('/register', { 
     controller: 'RegisterController', 
     controllerAs: 'vm', 
     templateUrl: '/static/templates/authentication/register.html' 
     }).otherwise({ 
     redirectTo: '/' 
     }); 
    } 

})(); 

/靜態/ JS /認證/控制器/寄存器.controller.js

/** 
* Register controller 
* @namespace myApp.authentication.controllers 
*/ 
/** 
* Register controller 
* @namespace kiwi.authentication.controllers 
*/ 
(function() { 
    'use strict'; 

    angular 
    .module('kiwi.authentication.controllers') 
    .controller('RegisterController', RegisterController); 

    RegisterController.$inject = ['$location', '$scope', 'Authentication']; 

    /** 
    * @namespace RegisterController 
    */ 
    function RegisterController($location, $scope, Authentication) { 
    var vm = this; 

    vm.register = register; 

    /** 
    * @name register 
    * @desc Register a new user 
    * @memberOf kiwi.authentication.controllers.RegisterController 
    */ 
    function register() { 
     Authentication.register(vm.email, vm.password, vm.username); 
    } 
    } 
})(); 

/static/js/authentication/authentication.module.js

(function() { 
    'use strict'; 

    angular 
    .module('myApp.authentication', [ 
     'myApp.authentication.controllers', 
     'myApp.authentication.services' 
    ]); 

    angular 
    .module('myApp.authentication.controllers', []); 

    angular 
    .module('myApp.authentication.services', ['ngCookies']); 
})(); 

回答

相關問題