我有一个非常基本的路线设置,允许我首先显示某个对象的“所有”记录。然后,如果用户选择一个下拉列表,他们可以使用日期对其进行过滤。
我最近升级到 RC2 并意识到“需要”已经替换或即将替换 controllerFor。
I'm curious how I can use "needs" in the below situation where I need the nested / inner route for "records.date" to change the content for the parent "records" route when a date is selected.
下面缺少的是在 App.RecordsDateRoute 内部,我需要将“记录”控制器的内容更改为新过滤器(这次按日期),而我似乎所做的一切只是转储车把模板并且什么都不显示-即使我尝试使用简单的东西,比如
this.controllerFor("records").set('content', App.Record.find(new Date(model.loaded)))
从 RecordsDateRoute 的 setupController 方法中
App.Router.map(function(match) {
return this.resource("records", { path: "/" }, function() {
return this.route("date", { path: "/:date_loaded" });
});
});
App.RecordsController = Ember.ArrayController.extend({
selected: 0,
dates: Ember.computed(function() {
return App.Date.find();
}).property()
});
App.RecordsIndexRoute = Ember.Route.extend({
model: function() {
this.controllerFor("records").set("selected", 0);
return App.Record.find();
}
});
App.RecordsDateRoute = Ember.Route.extend({
model: function(params) {
//the controllerFor below seems to be working great ... but what about needs?
this.controllerFor("records").set("selected", params.date_loaded);
return App.Date.create({ loaded: params.date_loaded });
}
});