How to use keepAlive on initial pages?

I have an app with a basic structure (Views as Tabs, with each tab containing a page)


<div class="view view-init tab" id="tab-2">
    <div class="page">Page content here</div>

Some data is fetched and inserted inside the page.

When I navigate to a new page and go back, the data is still here. But when I navigate 2 page deeper (home → page2 → page3 → back → back) then the data is not there anymore.

I understand that I have to use keepAlive: true (and it works well for traditional routes) but my question is how do I use the keepAlive parameter on “initial” pages, the ones that are already in the DOM in index.html when the app is initialized, and not dynamically loaded with routes? I tried data-keep-alive=“true” on the div tag but it doesn’t work.

1 Like