ocombe / ocLazyLoad

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

"controller is not a function", when assign it on "var" module #369

Closed maherAshori closed 7 years ago

maherAshori commented 7 years ago

app.js var sampleApp = angular.module("SampleApp", []);

controller.js sampleApp.controller("Sample.GetController", function ($scope) { var self = this; self.name = "Hello World"; });

when i define controller as above code i get this error: angular.js:13550 Error: [ng:areq] Argument 'Sample.GetController' is not a function, got undefined

for handle this i use " angular.module("SampleApp").controller()", but my project is so big!, and i want to handle that as easily way if possible.

Thanks

maherAshori commented 7 years ago

I handle that by this code

sampleApp .config(["$provide", "$compileProvider", "$controllerProvider", "$filterProvider", function($provide, $compileProvider, $controllerProvider, $filterProvider) { sampleApp .controller = $controllerProvider.register; sampleApp .directive = $compileProvider.register; sampleApp .filter = $filterProvider.register; sampleApp .factory = $provide.factory; sampleApp .service = $provide.service; sampleApp .constant = $provide.constant; } ]); `