Keep State of UI for View


#1

Is there any way with angular-ui-router to actually preserve the state of the UI like most native apps do?
For example, if I was on the home view and I clicked an accordion list which expanded, then clicked on that item inside the list and navigated to another view. Next, I decide to go back to the home view. The result I would like to have is the accordion list still expanded when navigating back to the home view.

Is there any way to preserve the actions/state of UI we navigating back and forth between views instead of a complete refresh of the view?


#2

I think I may have found something that may work. Its called UI-Router Extras.


#3

I wonder if this would reduce the rendering of the previous state? If so, it would be very nice. I could not deduce whether this would work sort of like cached state and render it much quicker than how it works currently.


#4

Hmm…It seem like I’m having a hard time using UI-Router-extras with my ionic app(my app does not include tabs).

Here’s a codepen to show an example.

http://codepen.io/markace1246/pen/BpzIv

I want to be able to keep the state of the accordion expanded UI when returning to the home page.


#5

use nested states and view states are preserved


#6

Patrick, could you please share a link to a working example or sth that could help understand this or see in action? I’m fighting with this without success as described here Prevent controller from reloading/rebuilding on state change and I’m ready to give up :frowning:


#7

I believe I attempted nested states in this code pen below,(correct me if I didn’t do it right), but I still can not get the accordion to stay expanded when return the previous state/view. Plus, the controller is reloading on return to state.

http://codepen.io/markace1246/pen/BpzIv

I wonder if it has something to do with the way ionic uses accordions(css & ng-show/hide).


#8

@markace1246: I agree that this, together with @rafaellop’s question, seems like an essential problem and I’d love to hear if you guys had any luck figuring it out? I’m bumping my head against the same thing…Thanks!


#9

Same issue +1. I tried ui-router-extras but it’s seems not working with ionic.