Angular2 ComponentRouter prevent automatic compone

2019-06-24 00:36发布

问题:

This question already has an answer here:

  • Angular2 Routing - keeping state of component when route changes [duplicate] 2 answers

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?

回答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