0

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?

1 Answer 1

1

The problem was the module was configured twice.

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.