Frank7390035
Posts: 0
Joined: Thu Feb 19, 2015 1:37 am

navigate-to resets local variables

Hello,

I have a page with a list of item populated via a local variable in a ionic app page.

When users leave this page and return via a back-button or navigate-to, the content is blank (the local and global variables are re-initialized).

Is this the intended behavior? I don't want any content reset to occur.

Thanks,
Frank

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

navigate-to resets local variables

Hello Frank,

Do you use global variables in ng-model properties of these form components?
Do you reset these variables on the ng-init functions?

Frank7390035
Posts: 0
Joined: Thu Feb 19, 2015 1:37 am

navigate-to resets local variables

Hi Serhil,

I am not using global variables for this specific page (however i found that also global variables are reinitialized after backbutton...e.g. via alert on the ng-init page)...

I am not resetting anything on ng-init..

Is this intended? If not, what settings should I check that may causing this?

thanks,
frank

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

navigate-to resets local variables

All local variables are resetting automatically in the ng-init function, so make them global to keep their values the same from page to page

Frank7390035
Posts: 0
Joined: Thu Feb 19, 2015 1:37 am

navigate-to resets local variables

Thanks Serhii. It doesn't work too well for me (can only get it to work if the global variable is inside activescreen).

Anyhow, I'm now using localStorage for this so it's half solved.

This is a ionic app, and in the past I was able to implement the back-button while preserving things like position of the scrollbar.

Is this intended not to work this way in ionic? Or is there a specific setting to keep cached back behavior like in a browser?

Thanks for your help!
Frank

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

navigate-to resets local variables

Do you use prelocation.back();/pre method for that?

Frank7390035
Posts: 0
Joined: Thu Feb 19, 2015 1:37 am

navigate-to resets local variables

I used navigate to home; but adding back-button to the ng-options doesn't worth either.

Based on your suggestion I also tried location.back() . and window.history.back()

all go back, but without remembering the history...

thanks for your help

Return to “Issues”