Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm using ocLazyLoad library to load on demand modules/files at angular.js. It works awesome and do what it needs to do. However, I'm having one issue when trying to load files from a file that was previously loaded on demand.

the error is this:

 Error: jsLoader is not a function
 this.$get</filesLoader@https : //localhost/js/angular/includes/lazyload.js:245:1

And the piece of code I'm using (this is the file that was previously loaded on demand. It is executed correctly and actually it tries to load the file, but the above error is what I can see. No ajax is done to try to get the file):

angular.module("App").config(function($stateProvider, $controllerProvider, $ocLazyLoadProvider) {
    $ocLazyLoadProvider.config({
        debug: true,
        events: true
    });
    $stateProvider.state("controller", {
        url: "/:controller/:action",
        controller: function($rootScope, $state, $stateParams, $ocLazyLoad) {
            if (!$rootScope.controllers)
                $rootScope.controllers = {};

            if (!$rootScope.controllers[$stateParams.controller]) {
                $ocLazyLoad.load([{
                    files: [
                        "/js/angular/controller/" + $stateParams.controller + ".js"
                    ]
                }]).then(function() {
                    $rootScope.controllers[$stateParams.controller] = true;
                    $state.go($stateParams.controller + ( $stateParams.action ? ("." + $stateParams.action) : "" ));
                });
            }
            log($stateParams);
        }
    })
});

Has anyone had this issue?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The problem was the module was configured twice.

The fix: https://github.com/ocombe/ocLazyLoad/commit/c590579c9512e0dd3fae2c33c0aefc0bb0f7ca7e

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.