在ember.js中获取包含动态段的当前路径

Pio*_*otr 7 ember.js

我想知道如何用动态元素获得Ember中的当前Path?我知道有

@get('currentPath') 
Run Code Online (Sandbox Code Playgroud)

在applicationController但这只给我"user.show",我也想能够像"/ users/1"那样检索路径.我知道我可以通过window.location.href来做到这一点,但还有其他("Ember")方法吗?

关心Piotr

小智 0

我不确定这是否符合 Ember Way,因为它没有在文档中列出,但控制器的目标对象既包含对 的引用document.location,也包含名为 的属性lastSetURL

this.get('target').location.lastSetURL; // "/foo/1"
Run Code Online (Sandbox Code Playgroud)