我有一个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调用。
致以敬意,
伊山
发布于 2018-06-05 00:52:55
您可能希望将您的model
和afterModel
移动到customers/index
路由,以获得您真正想要的行为。在没有看到更多代码的情况下,这有点像是一个猜谜游戏。
您可以使用currentRouteName method on the RouterService来检查是否进行转换,但我怀疑这将绕过不正确的设计,并为您自己积累麻烦。
https://stackoverflow.com/questions/50676775
复制相似问题