【发布时间】:2015-02-21 23:12:51
【问题描述】:
为什么我不能在这种情况下将Id作为参数传递:
App.Router.map(function () {
this.route("home", {path: '/'});
});
App.HomeRoute = Ember.Route.extend({
model: function () {
// return this.store.find('post');//works
return this.store.find('post',1);//does not
},
setupController: function (controller, model) {
controller.set('info', model);
}
});
小提琴:http://jsfiddle.net/3bfsddvo/2/
参考: http://emberjs.com/guides/models/finding-records/#toc_finding-a-single-record
我知道我正在尝试从我的“家”路线执行此操作,所以我猜如果创建了一个 posts/[:id] 路线,它会工作得更好。
如何在我的主路由中只返回一个帖子?
【问题讨论】:
标签: ember.js ember-data handlebars.js