ui-router-extras icon indicating copy to clipboard operation
ui-router-extras copied to clipboard

Exit a sticky state

Open ojacquemart opened this issue 9 years ago • 8 comments

Is there a simple way to exit a sticky state?

My use case:

  • I have a sticky state which opens a panel
  • The panels has a close button

I tried to use $stickyState.reset('*') but it does not do anything. I tried also to use $previousState.go() but without success.

Any ideas?

ojacquemart avatar Feb 16 '16 08:02 ojacquemart

I managed to get it work with a state reload:

$state.go($state.current.name, $stateParams, {reload: true});

But it is maybe not the most elegant situation?

ojacquemart avatar Feb 16 '16 08:02 ojacquemart

I have used the same solution above and I think it's fine - the reload parameter is there for a reason I suppose!

ry8806 avatar Feb 21 '16 19:02 ry8806

Is there any way to exit sticky state without reloading?

eden-lane avatar Mar 01 '16 15:03 eden-lane

do you mean leaving one sticky state for another sticky state?

ry8806 avatar Mar 01 '16 18:03 ry8806

Well, I was wrong: it's not about exiting state without reload, it's about entering state without reload. I have state posts with param ?page. On that page I have button "load more". When user clicks it I add +N posts and change url to "posts?page=2". If after that I click on post to open it in the sticky state, posts state will be reloaded. I'm looking for a way to prevent it

eden-lane avatar Mar 02 '16 09:03 eden-lane

I mean exiting a sticky state.

I do a $state.go('panel') which is a sticky state. I just want to exit that sticky state by clicking on a button, for example. Native ui-router provides a ui-sref=^. Is there any way to do that with a sticky state?

ojacquemart avatar Mar 02 '16 14:03 ojacquemart

+1

yy-dev7 avatar Mar 15 '16 02:03 yy-dev7

$stickyState.reset() only closes inactive states

I think you can use previous state to go back to wherever you came from and then close the state with $stickyState.reset() if you don't want it to persist.

ghost avatar Jul 08 '16 19:07 ghost