首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在浏览器上刷新重定向到以前的控制器?

在浏览器上刷新重定向到以前的控制器?
EN

Stack Overflow用户
提问于 2018-06-04 16:54:56
回答 1查看 89关注 0票数 -1

我有一个ember应用程序。路由的设置类似于。

customer 
customer/view/:customerId 
customer/dashboard 
customer/device-sharing

Customer/dashboard页面显示一个组件,即一个表,其中包含一个带有路由客户的#linkto helper。设备共享

这和预期的一样工作。问题是,一旦在设备共享路由上,如果我点击浏览器上的刷新按钮,应用程序将被重定向到仪表板路由。

编辑:

router.js:

this.route('customers', function() {
  this.route('index', {path: '/'});
  this.route('view', {path: '/view/:device_id'});
  this.route('dashboard', {path: '/dashboard/:customer_id'});
  this.route('device-sharing', {path: '/device-sharing'});
});

问题是,在customer.js路由文件的afterModel函数中,我们使用transitionTo转到仪表板。

afterModel(model) {
  model = model || [];
  if (model.length === 1) {
    console.log('Route parent');
    this.transitionTo('customers.dashboard', this.get('paramValue'));
  }
}

有没有办法检查设备共享子路由是否处于活动状态,以便我们可以阻止transitionTo调用。

致以敬意,

伊山

EN

回答 1

Stack Overflow用户

发布于 2018-06-05 00:52:55

您可能希望将您的modelafterModel移动到customers/index路由,以获得您真正想要的行为。在没有看到更多代码的情况下,这有点像是一个猜谜游戏。

您可以使用currentRouteName method on the RouterService来检查是否进行转换,但我怀疑这将绕过不正确的设计,并为您自己积累麻烦。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50676775

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档