Ember.js RC1 get name of route(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.
我有这样的东西(咖啡脚本)
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 获取路由名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Ember.js RC1 获取路由名称
基础教程推荐
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 响应更改 div 大小保持纵横比 2022-01-01
- 动态更新多个选择框 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01