ocLazyLoad: Controller not getting loaded

I have written one controlller js LoginController.js. I want include it only for login state. So i have written code in app.js like

var FrontEnd = angular.module("FrontEnd", ['ui.router', 'oc.lazyLoad']);

FrontEnd.config(['$ocLazyLoadProvider', function($ocLazyLoadProvider) {
      // We configure ocLazyLoad to use the lib script.js as the async loader
      $ocLazyLoadProvider.config({

      });
  }]);

FrontEnd.config(function($stateProvider, $urlRouterProvider) { 


    $stateProvider
        .state('login', {
            url: '/login',
            templateUrl:  BASE_URL + '/default/index/template/name/login',
            controller: 'LoginController',
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'FrontEnd',
                        insertBefore: '#ng_load_plugins_before',
                        files: [
                            'js/controllers/LoginController.js'
                        ] 
                    });
                }]
            }
        });

    $urlRouterProvider.otherwise('/login');
});

And my LoginController.js is:

FrontEnd.controller('LoginController', function() {
    console.log("In Login Controller");

});

For now I am trying only to see where it comes in controller or not. When I directly include my LoginController.js in layout, it works perfectly but when I try with loading using lazy loader it gives me blank screen. It does not show even any error in console. Please help me out, its urgent. Using version 0.5.1.

Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 35 (13 by maintainers)

Most upvoted comments

if the problem persists, note that you have to define module name in lazy load returned object, i.e:

loadMyCtrl: [‘$ocLazyLoad’, function ($ocLazyLoad) { // you can lazy load files for an existing module return $ocLazyLoad.load({ name:‘app’,//must include angular module name files: [‘js/controllers/BillingController.js’] }); }]