【问题标题】:Transition to current route with different upstream/parent dynamic segment in ember?在 ember 中过渡到具有不同上游/父动态段的当前路由?
【发布时间】:2015-06-15 13:46:12
【问题描述】:

我有一个特殊情况。

假设我在root.com/product/1/detail

我希望能够更改产品动态段,但仍处于详细子路径中。例如 `root.com/product/2/detail

如果我在root.com/product/1,我希望将相同的转换代码转到`root.com/product/2

通常情况下,您会输入transitionToRoute('product', this.get('id')) 之类的内容,但这只会将我带到产品路线。我需要额外的灵活性来保留访问者当前可能所在的任何子路线。

也许有某种“currentRoute”属性我可以像transitionToRoute('controller.currentRoute', this.get('id')) 这样在为动态段传递新的ID 或对象时挂钩?

【问题讨论】:

    标签: ember.js dynamic-url


    【解决方案1】:

    您可以使用以下方式设置当前路线:

    currentRoute = App.__container__.lookup('controller:application').get('currentPath')
    

    那么你应该能够按照你提到的方式做一些事情:

    transitionToRoute('currentRoute', this.get('id'))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-19
      相关资源
      最近更新 更多