I wan’t to create a navigation bar, with a list of items that comes from a RESTful service, I thought that the best way to do this is creating a new Component backed by a Model. I’m wrong?, if so, which is the best practice to achieve this?
import Ember from 'ember';
export default Ember.Component.extend({
model: function() {
return this.store.findAll('profile');
},
});
There are two problems with this snippet, model is a hook in Ember.Route, and store is not available in Ember.Component.
Even if store was available, if you tried to bind {{model}} in the template you would get the actual function, and not the result since it’s not a computed property.
The best practice is to load the data necessary in the parent route of the component. If the component is inserted in the application template, then you should load the data in the application route. Something like: