嵌套网址:路由转换的问题 [英] Nested URLs: issues with route transition

查看:130
本文介绍了嵌套网址:路由转换的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在努力使用Ember.js,并且遇到了我当前路由设计的一个问题,他们有嵌套的URL,但没有嵌套模板,所以他们的配置如下所示:

  this.resource('customer',{path:'/ Customer /:id'}); 
this.resource('employees',{path:'/ Customer /:id / Employees'});

现在,在Customers /:id(提交操作之后)在DS中创建一个新的Customer实例。存储和一组空的Employee对象也被添加到DS.store中。



问题是从客户转变为员工,员工模板实际上没有被渲染,维护客户模板。最后一个日志消息是尝试过渡到员工。



你能给我一个提示可能是什么问题吗?

解决方案

由于您的路由器,Employees路由不知道其父路由是什么,虽然您定义了此层次结构中的路径,但您应该使用嵌套路由(资源)。

  this.resource('customer',{path:'/ customer /:id'},function(){
this.route('employees',{path:'/ employees'});
});


I am currently struggling to get on board with Ember.js and I bumped into an issue with my current routes design, they have nesting URLs, however there are no nesting templates, so their configuration looks like this:

 this.resource('customer', { path: '/Customer/:id' });
 this.resource('employees', { path: '/Customer/:id/Employees' });

Now, at Customers/:id (after submit action) a new Customer instance is created in DS.store and a set of empty Employee objects are added, as well, into the DS.store.

The problem is transitioning from 'customer' to 'employees', the 'employees' template is not actually rendered, 'customer' template is maintained. The last log message is "Attempting transitioning to employees'.

Could you please give me a hint what might be the problem?

解决方案

Because of your router, Employees route does not know what its parent route is. Although you defined the path in this hierarchy, you should be using nested routes (resources).

 this.resource('customer', { path: '/customer/:id' }, function() {
    this.route('employees', {path: '/employees'});
 });

这篇关于嵌套网址:路由转换的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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