ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

http://errors.angularjs.org/1.5.0/ng/areq?p0=DashboardController not a NaNunction got undefined #295

Open Zhang-Yida opened 8 years ago

Zhang-Yida commented 8 years ago

// Dashboard .state('dashboard', { url: "/dashboard.html", templateUrl: "views/dashboard.html", data: {pageTitle: 'Admin Dashboard Template'}, controller: "DashboardController", resolve: { deps: ['$ocLazyLoad', function ($ocLazyLoad) { return $ocLazyLoad.load({ name: 'MetronicApp', insertBefore: '#ng_load_plugins_before', // load the above css files before a LINK element with this ID. Dynamic CSS files must be loaded between core and theme css files files: [ '../../../assets/global/plugins/morris/morris.css', '../../../assets/admin/pages/css/tasks.css',

                    '../../../assets/global/plugins/morris/morris.min.js',
                    '../../../assets/global/plugins/morris/raphael-min.js',
                    '../../../assets/global/plugins/jquery.sparkline.min.js',

                    '../../../assets/admin/pages/scripts/index3.js',
                    '../../../assets/admin/pages/scripts/tasks.js',

                    'js/controllers/DashboardController.js'
                ]
            });
        }]
    }
})

I am using ui-router with the latest oclazyload#1.0.9, and this happened! Is anyone else has the same quz? How to resolve it ??

sajumani commented 8 years ago

hi,

Am also getting same error, when i trying to load controller via lazy load,

Js file has been loaded in decided location but controller Function not initialized ...

youyouttok commented 8 years ago

Like this, in app.js

 app .config(["$provide", "$compileProvider", "$controllerProvider", "$filterProvider",
    function($provide, $compileProvider, $controllerProvider, $filterProvider) {
      app.controller = $controllerProvider.register;
      app.directive = $compileProvider.register;
      app.filter = $filterProvider.register;
      app.factory = $provide.factory;
      app.service = $provide.service;
      app.constant = $provide.constant;
    }
  ]);
sajumani commented 8 years ago

This wont work app.controller('HomeCtrl',function(){});

use == > angular.module('app').controller('HomeCtrl',function(){});