$ionicHistory.goBack() clears textbox value


#1
  1. From View A, there’s a button I click to go to View B using $state.go('viewB');

  2. View B has a <input type="text" />.

  3. I click <ion-nav-back-button> which triggers $ionicHistory.goBack() to go back to View A.

  4. If I click the button in View A to View B again, the value I typed in the textbox in View B is gone. The textbox is just empty.

Is there a way to prevent this or what is the way to solve this?


#2

I don’t know, but did you assume input to any variable?

<input type="text" placeholder="text" ng-model="data.text">

i hope this will work :slight_smile:


#3

one possible solution is to store the data in the model. ng controllers are destroyed on view/state changes, so you’ll have to persist that value somewhere else or mess around with ionic caching options to keep the controller alive. but you also need some ng-model for the input field for this to work.