0

i have put the ui-router-extras into my project to add state by lazy load module, it works fine, and i put the controller , factory , provider etc into to another module just like module1.controller. the module1 depend the module.controller, the state defined in module1 require the controller which has defined in module.controller. the module1 code :

    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'
        };
...

the module1.controller code:

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();

});

when the app run, i got an exception : Error: [ng:areq] Argument 'Ctl1' is not a function, got undefined

what can i do for it?

Seth
  • 1
  • 1
  • Before you'll get your answer, you can check these Q&A, with detailed how to and working plunker: http://stackoverflow.com/a/27754025/1679310 or http://stackoverflow.com/a/27466890/1679310 – Radim Köhler Feb 11 '15 at 06:19
  • i have put the demo into [plunker](http://plnkr.co/edit/ZucFgzyZfIdgXVFLMLUP?p=preview), why it not works, and how to let it work? – Seth Feb 12 '15 at 02:02

0 Answers0