This worked for me on 1.3.0-beta (and a quick glance at the source for 1.1.2 suggests it would work there too):
App.__container__.lookup('router:main').location.lastSetURL
Note that the documentation states:
At present, it relies on a hashchange event existing in the browser.
However, I believe it's strongly suggested that App.__container__
not be used in production code. A more acceptable alternative would be to use App.Router.router.currentHandlerInfos
, which provides information on the current Ember route.
Yet another option is currentRouteName
on the ApplicationController
. You can add needs: ['application']
to your controller, then access the route name with controllers.application.currentRouteName
. This will return something like posts.index
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…