Skip to content

Instantly share code, notes, and snippets.

@zollinger
Last active May 25, 2016 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zollinger/dd8654ef43fededb789c9cc5ee136da2 to your computer and use it in GitHub Desktop.
Save zollinger/dd8654ef43fededb789c9cc5ee136da2 to your computer and use it in GitHub Desktop.
Services with Angular 1.* and ES6
import BaseService from './base.service';
class AnalyticsService extends BaseService {
constructor($http) {
'ngInject';
super(...arguments);
}
fetchSomething() {
return this.$http.get('/api/analytics/something');
}
}
export default AnalyticsService;
import angular from 'angular';
import AnalyticsService from './analytics.service';
angular.module('app', [])
.service('Analytics', AnalyticsService);
class BaseService {
constructor(...dependencies) {
dependencies.forEach(dependency, dependency => this[dependency] = dependency);
}
}
export default BaseService;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment