Ember.js RC1获取路由的名称 [英] Ember.js RC1 get name of route

查看:119
本文介绍了Ember.js RC1获取路由的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ember应用程序,我做一些条件重定向,但希望能够将通过的请求传递到它的原始位置,当用户跳过一些箍。

I have an ember application where I do some conditional redirecting, but would like to be able to pass the request on through to it's original location after the user has jumped through some hoops.

我有这样的东西(coffeescript)

I've got something like this (coffeescript)

Ember.Route.reopen: ->
    redirect: ->
        if @controllerFor('specialOffers').get('should_offer')
            #This next line is what I need help with
            @controllerFor('specialOffers').set('pass_through', HOW_DO_I_GET_STRING_NAME_OF_CURRENT_ROUTE)
            # After this property is set and the user interacts
            # with the special offers, they will be redirected back
            # to wherever they intended to go
            @transitionTo('specialOffers')


推荐答案

但我不知道是否是获取此值的合法方式。

This seems to work... but I don't know if it is a legitimate way to get this value.

Ember.Route.reopen({
  redirect: function() {
    console.log(this.routeName);
  }
})

JSFiddle示例

这篇关于Ember.js RC1获取路由的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆