我已将ui-router-extras放入我的项目以通过延迟加载模块添加状态,它工作正常,我将控制器、工厂、提供程序等放入另一个模块,就像 module1.controller 一样。module1 依赖于module.controller,module1 中定义的状态需要module.controller 中定义的控制器。模块1代码:
define(['angularAMD',
'ngload!module1.controller'], function (angularAMD) {
var app = angular.module("module1", ['ui.router', 'module1.controller']);
var mainState = {
name: 'module1',
url: '/module1',
template: '<h1>Module1</h1><h4>This state was dynamically loaded from module1.js</h4>' +
'<div>module1.js defines 3 nested states</div>' +
'<div><a ui-sref=".state1">go to state1</a></div><div ui-view></div>',
controller: 'Ctl1'
};
...
module1.controller 代码:
define(['angular', 'angularAMD'], function (angular, angularAMD) {
var controller = angular.module("module1.controller", []);
controller.controller("Ctl1", ['$scope', function ($scope) {
$scope.Welcome = {};
$scope.Welcome.Message = "welcome to module1";
}]);
angularAMD.processQueue();
});
当应用程序运行时,出现异常:错误:[ng:areq] Argument 'Ctl1' is not a function, got undefined
我能做些什么呢?