ocombe / ocLazyLoad

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

TypeError: Cannot read property 'name' of undefined | ocLazyLoad #279

Open vinayakvinay opened 8 years ago

vinayakvinay commented 8 years ago

Hi there,

I am getting an error with nested angular states. ocLazyLoad works fine with independent state but when I inherit the state it throws a following error message.

I included the $stateProvider block below for your reference.

TypeError: Cannot read property 'name' of undefined
    at h (angular-ui-router.min.js:7)
    at g (angular-ui-router.min.js:7)
    at l.$broadcast (angular.js:14700)
    at u.transition.L.then.u.transition.u.transition (angular-ui-router.min.js:7)
    at angular.js:13168
    at l.$eval (angular.js:14381)
    at l.$digest (angular.js:14197)
    at angular.js:14420
    at e (angular.js:4900)
    at angular.js:5280
$stateProvider
        .state('content', {
            abstract: true,
            url: "/content",
            templateUrl: "views/common/content.html"
        })
        .state('content.dashboard', {
            url: "/dashboard",
            templateUrl: "views/dashboard.html",
            data: {
                pageTitle: 'Dashboard'
            },
            resolve: {
                loadPlugin: function($ocLazyLoad) {
                    return $ocLazyLoad.load([{
                        serie: true,
                        name: 'angular-flot',
                        files: ['js/plugins/flot/jquery.flot.js', 'js/plugins/flot/jquery.flot.time.js', 'js/plugins/flot/jquery.flot.tooltip.min.js', 'js/plugins/flot/jquery.flot.spline.js', 'js/plugins/flot/jquery.flot.resize.js', 'js/plugins/flot/jquery.flot.pie.js', 'js/plugins/flot/curvedLines.js', 'js/plugins/flot/angular-flot.js', ]
                    }, {
                        files: ['js/plugins/jvectormap/jquery-jvectormap-2.0.2.min.js', 'js/plugins/jvectormap/jquery-jvectormap-2.0.2.css']
                    }, {
                        files: ['js/plugins/jvectormap/jquery-jvectormap-world-mill-en.js']
                    }, {
                        name: 'ui.checkbox',
                        files: ['js/bootstrap/angular-bootstrap-checkbox.js']
                    }]);
                }
            }
        })
        .state('login', {
            url: "/login",
            templateUrl: "views/login.html",
            data: {
                pageTitle: 'Login',
                specialClass: 'gray-bg'
            },
            controller: 'UserController'
        })
        .state('register', {
            url: "/register",
            templateUrl: "views/register.html",
            data: {
                pageTitle: 'Register',
                specialClass: 'gray-bg'
            },
            controller: 'UserController'
        })
        .state('forgot', {
            url: "/forgot",
            templateUrl: "views/forgot.html",
            data: {
                pageTitle: 'Forgot password',
                specialClass: 'gray-bg'
            },
            controller: 'UserController'
        })
        .state('content.timesheet', {
            url: "/timesheet",
            templateUrl: "views/timesheet.html",
            data: {
                pageTitle: 'Timesheet'
            },
            controller: 'TimesheetController',
            resolve: {
                loadPlugin: function($ocLazyLoad) {
                    return $ocLazyLoad.load([{
                        insertBefore: '#loadBefore',
                        name: 'toaster',
                        files: ['js/plugins/toastr/toastr.min.js', 'css/plugins/toastr/toastr.min.css']
                    },{
                        name: 'datePicker',
                        files: ['css/plugins/datapicker/angular-datapicker.css', 'js/plugins/datapicker/angular-datepicker.js']
                    }
                    ]);
                }
            }
        })
        .state('content.consultant', {
            url: "/consultant",
            templateUrl: "views/consultant.html",
            data: {
                pageTitle: 'Consultant'
            },
            controller: 'ConsultantController',
            resolve: {
                loadPlugin: function($ocLazyLoad) {
                    return $ocLazyLoad.load([{
                        insertBefore: '#loadBefore',
                        name: 'localytics.directives',
                        files: ['css/plugins/chosen/chosen.css','js/plugins/chosen/chosen.jquery.js','js/plugins/chosen/chosen.js']
                    },{
                        files: ['js/plugins/jasny/jasny-bootstrap.min.js'] // For Cell no format
                    }
                    ]);
                }
            }
        });
sukrosono commented 8 years ago

you should use markdown , so it's readable

ocombe commented 8 years ago

I updated his comment (repo owned privileges!).

Hmm are you sure that the error comes from ocLazyLoad?

hgrourou commented 7 years ago

i face the same problem, how do you fix it?