最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - can we view all the routes in emberjs aka something similar to what rake routes does in rails - Stack Overflow

programmeradmin0浏览0评论

As the routes file in emberjs is becoming large, I am finding it difficult to keep track of all the routes supported by emberjs app, rake routes in rails gives a list of routes in the rails app, is there a way to generate routes in similar fashion for emberjs?

As the routes file in emberjs is becoming large, I am finding it difficult to keep track of all the routes supported by emberjs app, rake routes in rails gives a list of routes in the rails app, is there a way to generate routes in similar fashion for emberjs?

Share Improve this question edited Apr 2, 2013 at 9:14 Bradley Priest 7,4581 gold badge30 silver badges33 bronze badges asked Apr 2, 2013 at 5:01 aswani521aswani521 3174 silver badges13 bronze badges 1
  • then this is more like a question for ember.js and not for rails – Aleks Commented Apr 2, 2013 at 8:49
Add a comment  | 

4 Answers 4

Reset to default 10

Currently you can access all existing routes with App.Router.router.recognizer.names or just the names using Ember.keys(App.Router.router.recognizer.names).

It's obviously not as extensive as the Rails routes but it gives a quick and dirty overview.

In current versions of Ember/Ember-cli this is Object.keys(App.__container__.lookup('router:main').router.recognizer.names), where App is the name of your Ember app.

To piggy back off of Bradley Priest's answer, this may seem obvious to seasoned programmers, but for newb's, you can run App.Router.router.recognizer.names command in the debug console in the browser (ie: Firebug in Firefox, Chrome Developer Tools, etc...) after you load your Ember app in the browser.

Also note that App should be whatever you named your Ember App in the application.js file.

None of the previous answers work anymore. This works for ember 2.18.2:

App.__container__.lookup('router:main')._routerMicrolib.recognizer.names

(again, where App is the name of your ember app)

ember-cli: 2.18.2 node: 6.11.1

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论