TransitionTo子路径,其中父项具有动态段

时间:2015-01-21 15:48:13

标签: javascript ember.js url-routing

正如标题所暗示的那样,我试图从行动中transitionTo寻找儿童道路。问题是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);

1 个答案:

答案 0 :(得分:2)

路由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);
相关问题