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 rather than refreshing the page.

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

user1361551
  • 159
  • 1
  • 9

1 Answers1

1

Checkout ui-router extras. I think "Deep State Redirect" probably what you are looking for.

Luffy
  • 2,257
  • 16
  • 24
  • I would say both Sticky States + Deep State Redirect – Chris T Aug 08 '14 at 17:36
  • This solution seems to be what I'm looking for. I'm having trouble getting it to work though. I've included ct-ui-router-extras.js in my index.html, added 'ct.ui.router.extras' to my module, and applied to the state section sticky: true & deepStateRedirect: true to my home view, where I have an accordion present. When I attempt to return to the page, the home view still refreshes the screen/view and the controller is being recalled. Am I missing something?(Maybe if I can get the controller from call itself again, that may help. I'm not sure) – user1361551 Aug 12 '14 at 12:50
  • I think I'm missing something with ui-view. Let me check that out – user1361551 Aug 12 '14 at 17:45
  • I currently have a single page app with no tabs. How would this work for a simple app that has 4 views and I only want to preserve 1 view's state UI? (I was confused how I could apply the tabs example on ui-router-extras to my single page app & navigation structure) – user1361551 Aug 19 '14 at 14:07
  • 2
    Did you use a named ui-view for the sticky state? – Chris T Sep 09 '14 at 13:21
  • @ChrisT Thanks, this has been killing me. Is the requirement for the ui-view to be named called out in the documentation? It definitely wasn't obvious to me. – ach Dec 10 '14 at 14:23