Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular ui router with angular loading bar #2260

Closed
furyscript opened this issue Sep 23, 2015 · 3 comments
Closed

Angular ui router with angular loading bar #2260

furyscript opened this issue Sep 23, 2015 · 3 comments

Comments

@furyscript
Copy link

I use angular loading bar and I want to show it when state change
This is the repo https://github.com/chieffancypants/angular-loading-bar

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

@wesleycho
Copy link
Contributor

Linking chieffancypants/angular-loading-bar#239 for twin issue.

I assume you are using jQuery as well to be using that selector?

I'm thinking this is really a bug in the api of that library - thoughts @nateabele @christopherthielen ?

@furyscript
Copy link
Author

Yes I including jQuery...
I need that loading bar wait state ready and DOM also, else I got error because it not found the selector...

@nateabele
Copy link
Contributor

Yeah, maybe throw in a $timeout()? The issue tracker is for bugs and feature requests only. Please take support issues to StackOverflow, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants