ui-router-extras
ui-router-extras copied to clipboard
Exit a sticky state
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?
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?
I have used the same solution above and I think it's fine - the reload parameter is there for a reason I suppose!
Is there any way to exit sticky state without reloading?
do you mean leaving one sticky state for another sticky state?
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
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?
+1
$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.