Home > Enterprise >  Avoid page destroyed and avoid trigger NgOnInit again Angular Ionic
Avoid page destroyed and avoid trigger NgOnInit again Angular Ionic

Time:06-16

I have 2 pages, Page A and Page B, that i use again twice.

Example my route:

Page A -> Page B -> Page A (second) -> Page B (second)

Or implemented in real app:

posting -> profile -> another posting -> another profile

The problem:

When navigate backward from Page B (second) to Page A (second) there is no problem. But, when navigate back again to Page B, Page B trigger NgOnInit again and when i check the variables on that page, it is empty. So, i conclude Page B was destroyed.

Question:
How to avoid destroy? i want when navigate back from Page A (second) to Page B, there is no changed, showing the page B condition that same like i opened before.

*info : Every url already use different parameter

CodePudding user response:

I used ionic route (IonicRouteStrategy) and agree that navigation work fine in ionic. My mistake is when navigate back, i used location.back() from angular library, didn't use defaultHref from ionic

  • Related