In Ember.JS, Is there a good reason to be doing this:
import Service, { inject } from '@ember/service';
export default Service.extend({
ajax: inject(),
getAll() {
return this.get('ajax').request(`api/users/`, {
method: 'GET',
contentType: 'application/json'
});
}
});
As opposed to this?
import Service, { inject } from '@ember/service';
export default Service.extend({
ajax: inject(),
getAll() {
return this.ajax.request(`api/users/`, {
method: 'GET',
contentType: 'application/json'
});
}
});
The second method looks cleaner IMO, but I'm wondering if there's a good functional reason to be using .get() over just referencing the service directly.
Aucun commentaire:
Enregistrer un commentaire