ocombe / ocLazyLoad

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

Error: Unable to load undefined at HTMLScriptElement.P.a.onerror #320

Closed vaibhav-jain closed 8 years ago

vaibhav-jain commented 8 years ago

When I load the view ('/app/configuration/') first time it works fine but when I try to load the view again I get error

ocLazyLoad.min.js:8 GET http://localhost:8080/app/undefined P @ ocLazyLoad.min.js:8(anonymous function) @ ocLazyLoad.min.js:8r @ angular.js:326h @ ocLazyLoad.min.js:8D @ ocLazyLoad.min.js:8load @ ocLazyLoad.min.js:8(anonymous function) @ ocLazyLoad.min.js:8r @ angular.js:326load @ ocLazyLoad.min.js:8$stateProvider.state.state.state.state.state.state.state.state.state.state.state.state.state.state.state.state.state.state.state.state.state.state.resolve.deps @ config.router.js:341e @ angular.js:4219k @ angular-ui-router.min.js:7j @ angular-ui-router.min.js:7(anonymous function) @ angular-ui-router.min.js:7resolve @ angular-ui-router.min.js:7v @ angular-ui-router.min.js:7y.transitionTo @ angular-ui-router.min.js:7y.go @ angular-ui-router.min.js:7(anonymous function) @ angular-ui-router.min.js:7(anonymous function) @ angular.js:16414e @ angular.js:4940(anonymous function) @ angular.js:5328
angular.js:11706 Error: Unable to load undefined
    at HTMLScriptElement.P.a.onerror (ocLazyLoad.min.js:8)
       .......................
        state(
          'app', {
            abstract: true,
            url: '/app',
            templateUrl: '/tpl/app.html',
            data: {loginRequired: true},
            resolve:{
              deps: ['$ocLazyLoad',
                function ($ocLazyLoad) {
                  return $ocLazyLoad.load([
                    '/dashboard/js/controllers/header.Controller.js'
                  ]);
                }
              ]
            }
          }
        ).state(
          'app.configuration', {
            url: '/configuration/',
            templateUrl: '/tpl/configuration.html',
            resolve: {
              deps: ['$ocLazyLoad',
                function( $ocLazyLoad ){
                  return $ocLazyLoad.load([
                    'angular-timezone-selector',
                    'ngTagsInput'
                  ])
                }
              ]
            }
          }
        )
     ..................
vaibhav-jain commented 8 years ago

Solved by loading files without ocLazyLoad.

lrishiraj007 commented 8 years ago

I am facing the same issues with loading files with ocLazyLoad.js

This is my config in routing ,

 $ocLazyLoadProvider.config({
            'debug': true, // For debugging 'true/false'
            'events': true, // For Event 'true/false'
            'modules': [{ // Set modules initially
                name : 'reportModule', // State1 module
                files: ['src/app/reportModule/controllers/reportModule.js','src/app/reportModule/models/reportModuleService.js']
            }]
        });

  $stateProvider.state('reportModule', {
            url: '/reportmodule',
            views: {
                "main": {
                    controller: 'ReportModuleController',
                    templateUrl: 'reportModule/views/reportModule.tpl.html'
                }
            },
            resolve: {
                loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load('reportModule'); // Resolve promise and load before view
                }]
            },
            data: {
                pageTitle: 'Report'
            }
        });

am getting error Something Like this, image

Other than that i want to tell you that my projects loads all the modules with grunt's tasks So how does that affect ondemand loading .? Can you Please help me ?

Regards.

DevFacts commented 6 years ago

I am facing the same problem. Trying to find the solution.