i tried out a simple application, but i am confused as when to use model hook in controller and when to go for model hook in route. Take this for example(using EmberCLI):
Template (templates/discovery.hbs)
{{#each model}}
<tr>
<td>
Q: {{ques}}
</td>
</tr>
{{/each}}
so i can define model in following two ways
**First Way (routes/discovery.js) **
import Ember from "ember";
export default Ember.Route.extend({
model : function(){
return this.store.all('questions') ;
}
});
This works just as expected, all the record of type questions are passed on and displayed in discovery.hbs template.
Second way (controllers/discovery.js)
import Ember from "ember";
export default Ember.ArrayController.extend({
model : function(){
return this.store.all('questions') ;
}
});
So this was expected to work in same way like the previous(atleast i expected it to), but this doesn't display any record. So what is difference if i define model in route or controller? What should be preferred?
model
in the code ismodel: computed.alias('content')
. And it should stay overridable because that is what you sometimes do insetupController
in the Route. – yorbro