Javascript Ember.JS中嵌套资源的路由命名
以下路由设置来自Ember.JS docs(),我必须处理一个等效的问题:Javascript Ember.JS中嵌套资源的路由命名,javascript,ember.js,routes,Javascript,Ember.js,Routes,以下路由设置来自Ember.JS docs(),我必须处理一个等效的问题: App.Router.map(function() { this.resource('post', { path: '/post/:post_id' }, function() { this.route('edit'); this.resource('comments', function() { this.route('new'); });
App.Router.map(function() {
this.resource('post', { path: '/post/:post_id' }, function() {
this.route('edit');
this.resource('comments', function() {
this.route('new');
});
});
});
根据文件和我自己的经验,除其他外,这一结果是通过以下途径得出的:
/post/:post_id/comments -> App.CommentsIndexRoute
然而,因为我想要一个特定于帖子的评论路线,所以我会期待它
/post/:post_id/comments -> App.PostsCommentsRoute
我的谬误到底是什么?为了实现我的目标,我必须改变什么。只有
路线
的人与他们的父母共享他们的名字资源
。如果您希望它显示为PostsCommentsRoute
,则更像这样(注意,我将其复数化以匹配您的示例,尽管url没有复数化)
App.Router.map(function() {
this.resource('posts', { path: '/post/:post_id' }, function() {
this.route('comments');
});
});