在控制台中访问新的Ember路由器 [英] Access the new ember router in the console
问题描述
是否有一个等效的功能来使用新的路由器以ember方式在控制台中获取currentPath?
之前,我可以这样做:
router.get(currentPath)
然而,似乎与新的路由器,你不能以相同的方式访问路由器。事实上,App.router只是返回未定义的。
这里的任何帮助将不胜感激。
编辑: / p>
在相关的笔记中,由于我无法访问 App.router
及其属性,我无法如何手动触发状态更改。例如,
App.router.transitionTo(some.state)
已经不再可行了。大家在做什么而不是现在呢?
我发现这个答案埋在github问题中。
App.container.lookup('router:main')。路由器
..返回路由器。您可以访问transitionTo和handleURL来手动触发状态更改。不完全确定如何像以前一样获取当前状态,但是您似乎可以访问路由器上的currentHandlerInfos属性来获取当前处理程序(duh)的数组。
<希望这样可以防止别人撕掉头发。
Is there an equivalent function to grab the currentPath in the console with the new router in ember?
Before, I was able to do this:
App.router.get("currentPath")
However, it seems with the new router, you can't access the router in the same fashion. In fact App.router simply returns undefined.
Any help here would be greatly appreciated.
edit:
On a related note, because I can no longer access App.router
and its properties, I can't figure out how to manually trigger state changes. For example,
App.router.transitionTo("some.state")
is no longer viable. What is everyone doing instead of this now?
I found the answer buried in github issues. Re-posting here for posterity.
App.container.lookup('router:main').router
..returns the router. You can access transitionTo and handleURL to manually trigger state changes. Not exactly sure how to get the current state like before, but it seems like you can access the currentHandlerInfos property on the router to get an array of the current handlers (duh).
Hope this prevents someone else from ripping out their hair.
这篇关于在控制台中访问新的Ember路由器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!