5

Documentation https://angular.io/docs/ts/latest/guide/router.html states

... By default, the router reuses a component instance when it re-navigates to the same component type without visiting a different component first. The parameters can change between each re-use...

but there is no hint how to change this default-behavior.

Is it possible to prevent the re-use?

prupp81
  • 161
  • 2
  • 4

1 Answers1

1

This is currently not supported. There are plans to add support for some configurability in one of the next versions.

See also the discussion in https://github.com/angular/angular/issues/9811

That's now fixed by https://github.com/angular/angular/pull/13124

See also https://www.softwarearchitekt.at/post/2016/12/02/sticky-routes-in-angular-2-3-with-routereusestrategy.aspx

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • thx, didn't see that one. so the documentation is wrong. There is no default, and no one can garantie that the param will never change because of deeplinking. – prupp81 Aug 05 '16 at 10:36
  • I don't get what you mean. – Günter Zöchbauer Aug 05 '16 at 11:19
  • But that's a strategy to reuse but not to prevent the reuse for in params change. Are there any ways to achieve this? – Raymond the Developer Feb 17 '17 at 06:33
  • 1
    I'm sure you can build a reuse strategy that does not reuse at all. I didn't try myself yet though. There is a situation where the route is different and the component should be reused (not reuse is the default) and the other is where the route stays the same but a parameter changed (defaults to reuse) where a custom reuse strategy should allow to also change that behavior. That's just what I remember from discussions to related GitHub issues. – Günter Zöchbauer Feb 17 '17 at 06:55
  • The article from softwarearchitekt is kinda hard to understand for a beginner like me. I guess it's worth testing it out and do some trial and error with it. Thanks! – Raymond the Developer Feb 19 '17 at 00:03
  • I know. I hope they will add a tutorial or cookbook to http://angular.io – Günter Zöchbauer Feb 19 '17 at 10:08