How to destroy the previous page content when navigation change from one page to another page.
I am unable to destroy the previous page when routing to another page like this._router.navigate([’/setting’]) from home page.
When the page is navigated back from setting page to home page content remains the same but I want to clear them.
It wil not destroy the dom. Ionic add the page in stack memory and it loads from there. What i need is to completely load new page instead from stack memory
Not that anybody need care about my opinion, but FWIW I consider this squarely within the realm of “framework stuff that app developers should not rely on behaving any particular way”. If the framework (or the underlying OS) decides “it would improve UX to cache pages”, so be it. Conversely, if it is decided “hey, we need some resources and are going to nuke some hidden elements out of the DOM at random points”, OK.
Every time I personally have encountered a situation where I would want to do something like OP is requesting, it boiled down to stale data being held in page controllers. Along the lines of:
…now we go to some other page, which somehow modifies thingy, but when we come back to this page, it’s still displaying the old thingy. An idiomatic way around this is to refactor the service to return Observable<Thingy>:
Now any changes are going to be reflected automatically in this page, regardless of when it is cached or evicted from cache. We are no longer at the mercy of any framework lifecycle event timing.