angular 4 router without router-outlet

 ̄綄美尐妖づ 提交于 2019-12-21 17:39:33

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!