I am currently implementing a custom state management in angular 4 based on angular router, basically without any router-outlet attaching and detaching components myself based on routing events.
It works fine until i try to navigate from a route with parameters to the same route with different parameters, then it crashes.
This plunkr ( watch the console ) explains my situation. Navigating from 'crisis center' to 'heroes' is fine, navigating from 'heroes' to 'hero 11' is fine, navigating from 'hero11' to 'hero12' throws the error
TypeError: Cannot read property 'component' of null
I know the router is supposed to work with an outlet, but i think it's weird that without it works partially, so I'm not even sure if this can be considered a bug or desired behavior.
I'm wondering if there's some configuration option that would allow this particular situation or should i just use another routing library and avoid the angular router?
This issue is solved by adding a 'never' configuration parameter to the Route's runGuardsAndResolvers configuration option, as seen in this commit.
来源:https://stackoverflow.com/questions/45216208/angular-4-router-without-router-outlet