TransitionTo child 路径,其中 parent 具有动态段

TransitionTo child path where parent has dynamic segment

如标题所示,我正在尝试 transitionTo 一个动作的 child 路径。问题是 Ember 说它找不到任何具有该名称的路径。查看 Ember 文档,我不知道我在这里做错了什么。我希望这里有人可能有专业知识来帮助我。

Ember 错误:

Uncaught Error: Assertion Failed: The route post.comments was not found

申请路线定义:

this.resource('post', { path: 'post/:post_id' }, function () {
    this.resource('comments');
});

动作中的transitionTo

route.transitionTo('post.comments', post_id);

路线 post.comments 不存在,因为您将 comments 定义为 resource 而不是 route。我想这应该可行:

this.resource('post', { path: 'post/:post_id' }, function () {
    this.route('comments');
});

route.transitionTo('post.comments', post_id);

然而,如果您确实需要将 comments 声明为资源,请使用:

route.transitionTo('comments', post_id);