Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access the new ember router in the console

Tags:

ember.js

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?

like image 200
Han Avatar asked Jan 01 '13 08:01

Han


1 Answers

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.

like image 80
Han Avatar answered Oct 19 '22 02:10

Han