How to save current step form data when next steps are clicked in steppers?

I have steppers at the top of the page and I have a button on each step that saves the data. The requirement is also to save if the step is changed. How do I save current step form data when next steps are clicked in steppers?

Existing step changes need to be saved before moving on to the next step.

Please advise!

Thanks!

You can put it all in a provider/service that acts as data storage. As it is a Singleton, the values in there are save until you restart the app. Or you use Ionic Storage to persist the data, then it also survives app restarts.

1 Like

i have logic for saving form data ie: i subscribe to Angular service method that makes a call to backend and returns the data or returns an error.

I know that i can use ionViewWillLeave method but i have it inside a component which is inside of a page. I tried converting that component to page…however ionViewWillLeave method is not recognized.

Please advise!

Thanks

I didn’t understand that. What exactly is not working where?

Basically need to save form before the user exits the component. What lifecycle hook should i use and how to ensure the saving function finishes before the redirect happens?

So you are looking for lifecycle events similar to page’s ionViewWillLeave for a component?