Maybe I am missing something, but I'm experiencing a problem with Ionic caching views previously visited, preventing the components from being re-initialized by Angular. The components are pulled from some cache and rendered as whatever data existed previously.
Example:
User A is logged into the application and starts on the 'Home' page with info relevant to user A. User A logs out and navigates to 'Log In'.
User B logs in from the same application and navigates to 'Home' page. Ionic see's that Home was previously visited (by user A) and instead of instantiating 'Home', the view is pulled from cache and displays everything that User A was seing.
I noticed ion-router-outlet adds page transitioning when navigation, and this transition swaps to the left, when the navigation goes "forward" and swipe right when the navigation goes "backwards". This data seems to read from the same history-source that stores cached views.
TL;DR How to control Ionic router history (url tree) from caching the views preventing angular to re-initialize the components?
Had the similar issue 2 days ago. i am now using the ionic lifecycle hook ionViewWillEnter
. and by forcing the logic in this hook i achieved my desired results.
Let me know if this is helpful :)
I solved my problem using Ionic's life cycle hooks to fire the behavior needed, since Ionic does not destroy og init Angular components from the stack if previously visited. This is a longer topic, and it seems some things in Ionic stack control is not 100% fixed yet. Here are the hooks I routinely implement now to make things work:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With