【发布时间】:2013-11-16 07:05:45
【问题描述】:
这是我的路由器的一部分:
this.resource('nodes', function () {
this.resource('allNodes', function () {
this.route('index');
this.route('new');
this.route('show', { path: '/:node_id/show' });
this.route('edit', { path: '/:node_id/edit' });
this.route('delete', { path: '/:node_id/delete' });
});
this.resource('services', function () {
this.route('index');
this.route('new');
this.route('show', { path: '/:service_id/show' });
this.route('edit', { path: '/:service_id/edit' });
this.route('delete', { path: '/:service_id/delete' });
});
...
在/nodes 路由中,我重定向到allNodes.index:
SettingsApp.NodesRoute = Ember.Route.extend({
redirect: function () {
console.log('NodesRoute.redirect > redirecting to %s', ROUTES.ALL_NODES);
this.transitionTo(ROUTES.ALL_NODES);
}
});
现在在我的应用程序的其他部分中,我直接使用 url 链接到服务:
#/nodes/services/71ae38cde8584dc9c4eea25e74e68310/show
但这不起作用,因为/nodes 的重定向正在启动。我该如何防止这种情况?
重定向必须仅在转到/nodes 时处于活动状态,而不是任何子网址。我必须在重定向之前通过检查currentPath 手动实现此过滤,还是有标准的方法来执行此操作?
【问题讨论】:
标签: ember.js url-routing