Page 1 of 1

navigate-to resets local variables

Posted: Mon Apr 02, 2018 1:35 am
by Frank7390035

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


navigate-to resets local variables

Posted: Mon Apr 02, 2018 6:40 am
by Serhii Kulibaba

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?


navigate-to resets local variables

Posted: Mon Apr 02, 2018 10:02 pm
by Frank7390035

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


navigate-to resets local variables

Posted: Wed Apr 04, 2018 6:44 am
by Serhii Kulibaba

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


navigate-to resets local variables

Posted: Sun Apr 08, 2018 10:11 pm
by Frank7390035

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


navigate-to resets local variables

Posted: Mon Apr 09, 2018 4:01 pm
by Serhii Kulibaba

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


navigate-to resets local variables

Posted: Mon Apr 09, 2018 9:33 pm
by Frank7390035

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