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

Exit a sticky state #293

Open ojacquemart opened 8 years ago

ojacquemart commented 8 years ago

Is there a simple way to exit a sticky state?

My use case:

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 commented 8 years ago

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?

ry8806 commented 8 years ago

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

eden-lane commented 8 years ago

Is there any way to exit sticky state without reloading?

ry8806 commented 8 years ago

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

eden-lane commented 8 years ago

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

ojacquemart commented 8 years ago

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?

yy-dev7 commented 8 years ago

+1

ghost commented 8 years ago

$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.