christopherthielen / ui-router-extras

THIS PROJECT IS NO LONGER MAINTAINED -- Extras for UI-Router for AngularJS. Sticky States (a.k.a. parallel states), Deep State Redirect (for tab-like navigation), Future States (async state definition)
http://christopherthielen.github.io/ui-router-extras/
MIT License
917 stars 211 forks source link

Angular ui-router-extras bug: adds a $$uirouterextrasreload parameter to url #181

Open arthur-kv opened 9 years ago

arthur-kv commented 9 years ago

When I reload my ui-router's state like this:

$httpProvider.interceptors.push(function($rootScope, $q, $localStorage, $injector, $window, $timeout) {
    return {
        response: function(response) {
            return response;
        },
        responseError: function(rejection) {
            if(rejection.status === 401) {
                var $state = $injector.get('$state');
                rejection.data.error = rejection.data.error  || 'Unauthorized';
                type = 'danger';
                delete $localStorage.user;                    
                $state.go('login', null, {reload: true});
                $timeout(function () {
                    $window.location.reload();
                }, 200);
            } 
            return $q.reject(rejection);
        }
    };
});

This is my login state:

$stateProvider.state('login', {
    url: '/login',
    title: 'Login',
    views: {
        'rootView': {
            templateUrl: 'user/login.html',
            controller: 'loginController'
        }
    }
});

I get a url parameter $$uirouterextrasreload

http://localhost:3000/#/login?$$uirouterextrasreload=0.40401903772726655

I included ui-router-extras like this:

angular.module('MyApp',
    [
        // ...
        'ui.router',
        'ct.ui.router.extras.core',
        'ct.ui.router.extras.sticky',
    ]
);

Maybe I'm mising somethig?

dubilla commented 9 years ago

I'm facing something similar where the property is appearing in $state.params and making it difficult to determine if there are no parameters currently on a given state.

christopherthielen commented 9 years ago

@banzai-samurai what version of ui-router are you using?

Note: this bug is related to a reload feature I added to ui-router-extras for issue #139 which allows you to specify {reload: state.name} on a transition to reload state.name and all children. In ui-router 0.2.13 and up, the query parameter is considered "non-url" is does not affect the URL.

I'm afraid that I won't be fixing this bug until I entirely remove the capability introduced for #139. I will be removing it eventually, because in 0.2.15, ui-router got native "reload this state and its children" support. In the meantime, upgrade to 0.2.13+ and the behavior should change.

@dubilla likewise, what versions of ui-router and extras are you using? How is the "$$uirouterextrasreload" param affecting you? What are you doing with the params object that makes this difficult for you?

arthur-kv commented 9 years ago

i'm using 0.2.12-pre1 version of ui-router

christopherthielen commented 9 years ago

@banzai-samurai that's an odd version to be using! why not update?

oddlyfunctional commented 8 years ago

+1