Remember view when routing

Hello all,

I am implementing a sidemenu-based Ionic application (using stateprovider for navigation). In this application I have a search page, which makes calls to a REST API. The results are displayed on the page, and when clicking a result the user is redirected to its details page.

The problem is, when navigating back (press the arrow-left or use the back on the device), the search page is clean and ‘refreshed’. The results are not there anymore, which obvious makes sense because the state has changed.

How can I force to ‘remember’ the page when navigating to a ‘sub page’?

EDIT: for now I store the results in the localStorage, but I would like to know if there is any ‘Ionic-way’ of doing this, for example don’t get rid of the view when opening a subview.

Thanks

state provider:

.state('app.search', {
    url: "/search",
    views: {
        'menuContent': {
            templateUrl: "templates/pages/search.html",
            controller: 'SearchCtrl'
        }
    }
})
.state('app.person', {
    url: "/persons/:personId",
    views: {
        'menuContent': {
            templateUrl: "templates/pages/person-detail.html",
            controller: 'PersonCtrl'
        }
    }
});

You could inject your data into the $rootScope. This will make them available throughout the app. When you call your service to that API with $http, set the attribute cache:true. So the API isn´t called when the data are in cache. Hope it helps :wink: Cheers.