Ember js多级深层命名空间

时间:2013-03-22 04:58:19

标签: ember.js

App.ApplicationRoute = Ember.Route.extend({
    setupController: function(){
        this.controllerFor('App.Namespace1.Object1').set('model', model);
    }    
});

App.Namespace1.Object1Controller = Ember.ObjectController.extend({});

这可行

App.ApplicationRoute = Ember.Route.extend({
    setupController: function(){
        this.controllerFor('App.Object1').set('model', model);
    }    
});

App.Object1Controller = Ember.ObjectController.extend({});

这是我看到的错误。

Error: assertion failed: You are trying to look up a controller that you did 
not define, and for which Ember does not know the model.

This is not a controller for a route, so you must explicitly define the controller 
(Minerva.Namespace1Object1Controller) or pass a model as the second parameter to 
`controllerFor`, so that Ember knows which type of controller to create for you.
http://localhost:8090/EmberApplication/js/vendor/ember-1.0.0-pre.2.js
Line 53

EmberJS是否支持多级深层的命名空间?

1 个答案:

答案 0 :(得分:1)

好消息!我刚刚删除了我的旧答案,因为仔细检查Ember.Resolver中的代码会发现以下情况应该是可能的:

this.controllerFor('App/Namespace1/object1')

(惯例是指小写路线上下文中的控制器)