I’m a beginner, still learning Ember. I’m currently using Ember 1.10 and ember-cli 0.1.12 (latest). I also am currently using firebase. I apologize if this question would be more appropriate for stack overflow.
Right now my app works, but I thought maybe there would be a more elegant way of doing things.
I have a simple model:
/models/employee.js
import DS from 'ember-data';
export default DS.Model.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string') ...
I have some routes as pods which are:
/pods/employee-form
/pods/employee-list
Now, I can push data onto the model in employee-form.hbs, that’s fine. The trouble is that I can’t seem to pull the data for /pods/employee-list unless I create another router file.
So, I can
/pods/employee-list/route.js
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.findAll('employee');
}
});
or I can put that some information into
/routes/employee-list.js
But isn’t there a way to make that same model available to all routes? When I try the store.find method on a route for index.js the data isn’t available?
I’ve tried adding the store.find on a controller as well with no luck.
Also - When I make the data available by setting the model on the route, in my htmlbars template I can’t seem to access the collection unless I state model:
{{#each employees as |employee|}}
{{employee.firstName}}
...
{{/each}}
does not work
{{#each model as |employee|}}
{{employee.firstName}}
...
{{/each}}
works