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']);
})();