如何在emberjs的嵌套控制器上执行“需求”?

时间:2014-11-14 15:41:44

标签: ember.js

我有以下路由器:

this.resource('foo', {path: '/foo'}, function() {
    this.resource('foo.bar', {path: '/bar'}, function() {
        this.route('wat', {path: '/wat'});
    });
});

我的FooBarWatController是一个单身人士,我需要访问FooBarController的模型。 needs FooBarWatControllerFooBarController的访问权限是什么意思?

FooBarWatContoller = Ember.ObjectController.extend({
    needs: ['?'],
    action: {
        something: function() {
            console.log(this.get('controllers.?.model').get('id'));
        }
    }
});

1 个答案:

答案 0 :(得分:1)

FooBarWatContoller = Ember.ObjectController.extend({
    needs: ['foo/bar'],
    action: {
        something: function() {
            console.log(this.get('controllers.foo/bar.model').get('id'));
        }
    }
});