In my Angular web application, I encounter a scenario where I need to navigate back to the previous state. Let's say I am currently on a page at http://localhost/someURL. On this particular page, users have the ability to search for items and see the results displayed in a list format (the URL remains the same). Each item in the list has a button that directs them to another component located at http://localhost/someURL2.
My inquiry is as follows: When a user clicks on a cancel button while on someURL2, how can I navigate back to someURL with the search results still preserved? Currently, even though I can successfully return to someURL using the provided code snippet below, the search results are not retained.
import { Location } from '@angular/common';
@Component({
......
})
export class SomeClass implements OnInit {
constructor(private location: Location) { }
backToPrevious(){
this.location.back(); //Does not show search results upon return
}
}