How to obtain the previous selected value on ion-select?


#1

I have a Select with ionChange event sending the new selected value to the backend for an update.
It happens that the server might reject the new value for some business rule or there’s some request issue.
How can I set the previous value to the select component?
Is there such thing as a “beforeChange” event? A way to keep the previous value?

If not, how could I accomplish this? I wish I don’t have to make a copy of the selected value before user interaction, when the page loads.

Thank you!


#2

Save the value in a temp variable before you make the server request.

When your server reject your call write the value back from the tmp variable to the variable you bind to your select.