2014-11-21 67 views
0

我有嵌套的路线是这样的:Emberjs:访问动态段嵌套路由/控制器

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

我需要的“用户”动态段在我的追随者/以下路线/控制器的值的访问。我想到的一种方法是使用

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

在我的追随者/追踪路线中。

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

感谢,

回答

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