我有一个非常基本的路由设置,它允许我首先显示某个对象的“所有”记录。然后,如果用户选择一个下拉菜单,他们可以使用日期过滤掉。如何在Emberjs中使用嵌套路由/控制器中的“needs”RC 2
我最近升级到RC2,并意识到“需求”已经取代或即将取代controllerFor。
我很好奇我如何在下面的情况下使用“需求”,我需要嵌套/内部路由为“records.date”来选择日期时更改父“记录”路线的内容。
从下面什么是缺少的是,在App.RecordsDateRoute我需要将“记录”控制器的内容更改为一个新的过滤器(此日期)和我似乎做的一切只是转储把手模板和显示什么 - 甚至当我尝试的RecordsDateRoute
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 });
}
});
的setupController方法中我有涉及加载从嵌套路线日期有点相关的问题,我已经放置** 50个**点柜面任何人想看看赏金:** http://bit.ly/15YQscl**。非常感谢。 – brg 2013-10-22 01:00:25
但在这里你使用了'needs:'在一条路径中。那么路由是否可以访问'records'控制器属性或'records'路由属性?是否包含控制器意味着您获得其控制器属性和路由属性? – ahnbizcad 2015-04-05 19:34:49