这是我路由器的一部分
App.Router.map(function () {
this.resource('report', {path: '/noticia/:report_id'}, function() {
this.route('pictures');
});
});
我已经定义了一个App.ReportPicturesController
但我的路由App.ReportPicturesRoute
坚持加载不同的控制器。
如果我不指定模型钩子,它会加载App.ReportController
,如果我加载我需要的模型(称为comment
)加载App.CommentController
。
我试图controllerName
设置为reportPictures
但没有奏效。
我必须做什么才能使路由加载ReportPicturesController
?为什么没有加载预期的控制器?
编辑:如果有任何区别,我使用的是ember
1.8.1,ember-data
1.0.0-beta.12,这就是路线的样子,
App.ReportPicturesRoute = Ember.Route.extend({
model: function(params) {
var report = this.modelFor('report');
return this.store.createRecord('comment', {
inReplyToStatus: report
});
}
});
编辑2:完整的源代码在 https://github.com/camolin3/tweetsaster
当我尝试时,它按预期工作.. 看看:
http://emberjs.jsbin.com/rayoje/2/
您缺少与此类似的 ReportRoute 模型钩子实现
App.ReportRoute = Ember.Route.extend({
model: function(params) {
return {id:params.report_id};
//or with ember-data return this.store.find('report', params.report_id);
}
});