2

Is there any way to preserve the history of your actions on the app?

Here is a basic flow of my app:

  1. search.page.ts find some records

  2. result.page.ts go to record view

  3. case.page.ts from record view navigate to a case this record is linked to

  4. result.page.ts from case click on record view again

When I click <ion-back-button /> I expect to return to case.page.ts.

However, what happens is I am redirected straight to search.page.ts.

It seems that when I navigate from case.page.ts the history of my clicks isn't building up but reverses because the page I am intending to go to has already been visited.

Question is how do I deal with this situation? Because my typical user definitely wants to return to case in this example.

Edit: I created a quick POC that tricks router into achieving my expected behaviour, but I don't like it, it was just a quick test, basically adding some random hash to the ID of the result, which tricks router into building a full path:

case.page.html

// link to result from case page
[routerLink]="['/record-view/', recordId+'3SRzrMbhcQGpA']"

result.page.html

// remove hash from the id passed from case
this.recordId = paramMap.get('recordId').replace("3SRzrMbhcQGpA", "");
f1vlad
  • 227
  • 3
  • 12
  • maybe [this article](https://ionicframework.com/blog/navigating-the-change-with-ionic-4-and-angular-router/) could help you – JSmith Oct 31 '19 at 00:30
  • I still would try adding [replaceUrl]="true" to your link see if that works – JSmith Oct 31 '19 at 00:53
  • This seems to be a similar case as [this](https://stackoverflow.com/questions/54892266/ionic-4-angular-back-button-to-previous-page-instead-of-root). Diff is the post is using tabs, however Location should help with the routing. – xlordt Oct 31 '19 at 01:24

0 Answers0