route.js
model() {
return this.store.findAll("post");
},
setupController(controller, model){
controller.set('model', model);
}
これはポストオブジェクトのコレクションですコンソール・ログ・モデルを提供します。
controller.js
init(){
console.log(this.model);
}
私たちは、あなたがあなたのコントローラ上のモデルがどうなるかを選択した RSVPの約束を使用する場合は特に回のこの大半を行います。これはまた、あなたのモデルを与えることも可能である
例
model(params) {
return Ember.RSVP.hash({
lecture: this.store.findRecord('section', params.section_id).then((section)=>{
return this.store.createRecord('lecture',{
section: section
});
}),
section:this.store.findRecord('section', params.section_id),
course: this.store.query('course',{filter:{section_id:params.section_id}})
});
},
setupController(controller,model){
controller.set('model', model.lecture);
controller.set('section', model.section);
controller.set('course', model.course);
}
注意あなたが唯一のルート
model(params) {
return this.store.findRecord('course', params.course_id);
}
上の単純なモデルを持っていて、コントローラ上の任意の設定を行う必要があります `tを場合オンコントローラ。
ここにあなたの質問に対する答えがあります。 http://stackoverflow.com/questions/27332840/how-to-access-ember-model-in-oninit-in-object-controller –