The back button works like a cancel, but I’ve got a case where I’d like to persist some form field values when the user goes back. localStorage is an option, but I’m wondering if there’s a better way.
To further describe what I’m looking for:
Screen 1: user fills out Form A, then taps “next”
Screen 2: user fills out the form, but needs to change something on Screen 1 so they hit “back”
How do I avoid losing all of the form values on screen 2?
So create an own service --> in your controllers of your screens you can listen on “stateChangeStart”-event of the ui-router (everytime you try to leave the page)
–> store the values of the screen in the service. If you enter the screen again (listen on $ionicView.beforeEnter event) http://ionicframework.com/docs/api/directive/ionView/
you can check if there are data for the screen in your service --> get them