I'm trying to implement a simple search engine in Angular 2. I have a component with a search field and a list of results leading to external URLs (to pages that are not part of the app) below the search field.
Let's say the user enters some search text, gets results from a service call in the background and then clicks on one of the results links which takes him to an external site. Then he perhaps decides to try some other result, so he clicks the Back button of his browser to get back to the search results. But the problem is that at this point the whole app gets reinitialized which means that the previous results are gone and the app just displays an empty search field as if it was opened for the very first time.
So, my question is: how do I preserve the state of the app across navigations to external sites? Do I have to use the Router and store the search string in the route? Or do I have to save the state somehow and restore it when the user returns back to the app? What is the recommended way of handling this use case?