Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Ember.JS中嵌套资源的路由命名_Javascript_Ember.js_Routes - Fatal编程技术网

Javascript Ember.JS中嵌套资源的路由命名

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'); });

以下路由设置来自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');
        });
    });
});
根据文件和我自己的经验,除其他外,这一结果是通过以下途径得出的:

/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');
    });
});