Emberjs:访问嵌套路由/控制器中的动态段

时间:2014-11-21 09:22:44

标签: ember.js ember-router

我有这样的嵌套路线:

  this.resource('profile', { path: '/:user' }, function(){
    this.route('followers');
    this.route('following');
  });

我需要访问' user'我的粉丝/后续路线/控制器中的动态细分。我想通过的一种方法是使用

  this.controllerFor('profile').get('user')

在我的粉丝/后续路线中。

这样做的正确方法是什么?

谢谢,

1 个答案:

答案 0 :(得分:0)

我认为你正在寻找route#modelFor

示例:

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

App.CommentsRoute = Ember.Route.extend({
    afterModel: function() {
        this.set('post', this.modelFor('post'));
    }
});
相关问题