-1
如何创建支持格式为“/ objects/1/fields/1”的嵌套URL的路由。如何在ember中创建支持pod结构的嵌套路由url?
我能够用下面的代码实现这一点,但它违反了我的代码的pod结构。
this.route('fieldShow', {path: '/objects/:object_id/fields/:field_Id'});
如何创建支持格式为“/ objects/1/fields/1”的嵌套URL的路由。如何在ember中创建支持pod结构的嵌套路由url?
我能够用下面的代码实现这一点,但它违反了我的代码的pod结构。
this.route('fieldShow', {path: '/objects/:object_id/fields/:field_Id'});
你试试这个:
Router.map(function() {
this.route('fieldshow', function() {
this.route('edit');
this.route('object', { path: ':object_id' }, function() {
this.route('field', { path: ':field_id' });
});
});
});
这可能帮助你。你可以忽略this.route('edit');这只是向你展示它是如何工作
我最终通过传递的路径是这样解决这个:
this.route('fields', {path: 'objects/:object_id/fields'}, function() {
this.route('show', {path: '/:field_id'});
});
它为什么会违反荚结构? – locks
在我给出的例子中,我将无法构造字段的文件。与“show”,“edit”,“new”等字段有关的所有文件都必须放置在路径的根目录中,而不是放置在pod结构之后的传统“fields”文件夹中。 –