Skip to content

$stateChangeStart event is not providing the options #1620

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

Closed
nielsboogaard opened this issue Dec 9, 2014 · 27 comments
Closed

$stateChangeStart event is not providing the options #1620

nielsboogaard opened this issue Dec 9, 2014 · 27 comments
Assignees
Milestone

Comments

@nielsboogaard
Copy link

To check whether the user is authorized for a certain state, i implemented an interceptor which listens to the $stateChangeStart event. After checking the rights, I resume the transition with the following code:

$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
    //Auth stuff checking here
    $state.go(toState, toParams, {notify: false}).then(() => {
        $rootScope.$broadcast('$stateChangeSuccess', toState, toParams, fromState, fromParams);
    });
});

I notify the stateChangeSucces by hand to prevent endless loops here. The problem is that state.go calls which provides optional options (like reload:true) are not provided by the $stateChangeStart event. This prevents resuming the started transition correctly (because the provided options as originally passed to the state.go method are lost).

Alternative would be to provide a method like $state.resume() which can be used to resume a prevented state transition which takes into account the passed params and options.

@fubupc
Copy link

fubupc commented Dec 11, 2014

👍

I have the same problem as well.

@OverZealous
Copy link

👍 Just caught this trying to figure out #1007

@cbeek
Copy link

cbeek commented Dec 17, 2014

👍

@RafaelVidaurre
Copy link

Same problem here

@sandermak
Copy link

+1!

@cbeek
Copy link

cbeek commented Dec 18, 2014

👍

1 similar comment
@mark-veenstra
Copy link

+1

@gustavohenke
Copy link
Contributor

+1.
They should be passed to $stateChangeSuccess too.

@flyskyko
Copy link

flyskyko commented Feb 2, 2015

+1

1 similar comment
@sebholstein
Copy link

+1

@nielsboogaard
Copy link
Author

Any updates on this from the angular-ui team? Is there a plan to solve this in a newer version?

@abhinandankothari
Copy link

Any Updates on this ? I am facing the same issue

@a14m
Copy link

a14m commented Feb 26, 2015

+1

3 similar comments
@josephbuchma
Copy link

+1

@SinisterLight
Copy link

+1

@qpitlove
Copy link

qpitlove commented Mar 9, 2015

👍

@nateabele
Copy link
Contributor

The upcoming release will have new APIs that obviate this.

@karser
Copy link

karser commented May 8, 2015

+1

@abhinandankothari
Copy link

is this fixed in 0.2.15 ?

@asperling
Copy link

👍

@christopherthielen
Copy link
Contributor

I think we can add options as a fifth (!!!) parameter to the $stateChange events. Who has time to make a PR?

@mrtomrichy
Copy link

Any news on this?

@thomas3577
Copy link

+1

2 similar comments
@jeroenlorrentop
Copy link

+1

@mambax
Copy link

mambax commented Aug 25, 2015

+1

@nateabele
Copy link
Contributor

Any news on this?

@mrtomrichy #1620 (comment)

scooper91 added a commit to scooper91/ui-router that referenced this issue Aug 26, 2015
- Add options as a 5th parameter to the $stateChangeStart event
- As per angular-ui#1620
@zamrokk
Copy link

zamrokk commented Mar 10, 2016

👍

ExpFront pushed a commit to ExpFront/ui-router that referenced this issue Jun 23, 2016
- Add options as a 5th parameter to the $stateChangeStart event
- As per angular-ui#1620
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests