How to determine it is from back or not in IonViewWillEnter

I am using Ionic 5 and I have a page to list some kind of products
This listing page can be routed by header bar.
And when clicking one of the product item in the listing page it will route to a product detail page.

No matter I route to the listing page by header bar or back from product detail page
it will call IonViewWillEnter.

And I would like to determine if the page is entered by the back event from product detail page,
or from header bar.

Use case is if back from detail page, I would like to keep current scrolling status
If from header bar, I would like to refresh the page and update the data and move scrolling to top.

How to do that?

Look at Angular’s Activated Route, it should fit the bill for you.

1 Like