@darrion.kuhn
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import Component from '@ember/component';
import { inject as service } from '@ember/service';
export default Component.extend({
myService: service(),
actions: {
fetchData() {
this.get('myService').getData().then(data => {
// Do something with the data
});
}
}
});
|
1 2 3 4 5 6 7 8 9 10 |
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default Route.extend({
myService: service(),
model() {
return this.get('myService').getData();
}
});
|
1 2 3 4 5 6 7 8 |
export function initialize(application) {
application.inject('route', 'myService', 'service:my-service');
}
export default {
name: 'my-service',
initialize
};
|