2013-05-13 29 views
7

我想知道如何使用動態元素獲取Ember中的當前路徑? 我知道有在ember.js中獲取動態段的當前路徑

@get('currentPath') 
在ApplicationController中

,但是這會給我的只有「user.show」,我想也能以檢索像「/用戶/ 1」路徑。 我知道我可以通過window.location.href做到這一點,但有沒有其他的(「Ember」)方式來做到這一點?

問候 彼得

+1

可能重複[如何檢索路徑的路徑?](http://stackoverflow.com/questions/16471068/how-do-i-retrieve-the-path-of-a-路線) – MilkyWayJoe 2013-05-13 16:34:59

+0

好吧,它是我想要的相反。我需要獲取路徑末端模型ID。所以我可以保留它進行進一步的重定向(例如sucessfull登錄後) – Piotr 2013-05-14 18:11:26

回答

0

我不知道這是否有資格作爲灰燼方式,因爲它不是在文檔中,但控制器的目標對象包含既document.location參考,也被稱爲lastSetURL屬性。

this.get('target').location.lastSetURL; // "/foo/1"