Skip to content

RouteReuseStrategy doesn't reuse the parent tree components #20072

Description

@gianmarcov

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] (Maybe) bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

When extend 'RouteReuseStrategy' with my reuse logic, only the child component
will be reused, the parent tree will be destroyed and recreated on every route change.

Expected behavior

When extend 'RouteReuseStrategy' with my reuse logic, i expect that not only the child component will be reused also the parent tree components.

Minimal reproduction of the problem with instructions

https://plnkr.co/edit/LQ2lgBrjWw6JeezdqNhl?p=preview

  1. type a number for simulate opening person to edit. (click on 'open person detail')
  2. change tab 'person'
  3. click on 'goto detail'
  4. type a number into the textarea -> parent component will show the value after living textarea
    (share same service instance)
  5. change back to home tab -> change back to person tab
  6. typed number will be displayed in the child textarea (reused route) but parent doesn't have a number anymore even if typing a new number. (because service instance are not the same)

What is the motivation / use case for changing the behavior?

What i want to archive is that i can provide the same service instance via dependency injection to the router-outlet children and the children can interact with the parent component. (This cannot be done as global service, because the route will be created dynamically with an id in the url (every route has it's own state, see plunker demo)).

Environment

Angular version: 4.3.1
For Tooling issues:
- Node version: v6.11.1
- Platform:  Windows

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions