Skip to content

Loading bar don't find parentSelector #239

Closed
@furyscript

Description

@furyscript

I use angular ui router and I want to show angular loading bar when state change

This part of code is in run method of main module app:

    $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
       cfpLoadingBar.start();
    });

    $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
        cfpLoadingBar.complete(); 
    });

I have this selector
cfpLoadingBarProvider.parentSelector = '.wrapper > section';

The problem is that the selector is in nested view and the $stateChangeStart starts before view is loaded so I got error from loading bar because it not found the selector.

This is the error
TypeError: Cannot read property 'lastChild' of undefined
    at Object._start [as start] (loading-bar.js:215)
    at app.js:253
    at Scope.parent.$get.Scope.$broadcast (angular.js:16238)
    at Object.transitionTo (angular-ui-router.js:3140)
    at Array.<anonymous> (angular-ui-router.js:2318)
    at Object.invoke (angular.js:4473)
    at handleIfMatch (angular-ui-router.js:1822)
    at angular-ui-router.js:1877
    at check (angular-ui-router.js:1992)
    at update (angular-ui-router.js:2001)

Any solution??

Thanks
FS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions