Skip to content

Components inside a nested router-outlet are recreated when navigating #802

@vakrilov

Description

@vakrilov

The Scenario

We have a following app scenario:

  • The app has root navigation using <page-router-outlet>
  • On one of the pages (let's name it "main") there is a nested navigation using the stock angular <router-outlet>. Navigating the nested router outlet is usually controlled with RadSideDrawer.

There are sample implementations described in #343 and in this gist by @NathanWalker

The Problem

When navigating form "main" page to another page(let's name it "detail") and then back again, the content of the nested <router-outlet> inside the main page is loaded after the page animation is finished:

router-outlet-caching

There are two different issues at hand:

  1. The component that was previously shown inside the <rotuer-outlet> is re-created and not reused.
  2. The actual instantiation of the component happens after the page animations has finished. This is triggered in the <page-router-outlet> implementation and happens in page.navigatedFrom event. Which means the "main" page is empty during the animation and the content is loaded after the navigations has finished.

Additional Information

The reason why page.navigatED From event is used instead page.navigatING From is that in IOS you can start a back navigation using swipe gesture, but cancel it in the middle:

may-16-2017 13-47-08

If we trigger the angular back navigation on the page.naivgatING event, angular will remove
the components form the current page and instantiate the component on the page you are navigation to. However, if you then cancel the animation you will end up with a page that has been cleared and corrupted navigations stack.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions