Last active
May 25, 2016 09:06
-
-
Save zollinger/dd8654ef43fededb789c9cc5ee136da2 to your computer and use it in GitHub Desktop.
Services with Angular 1.* and ES6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import angular from 'angular'; | |
import AnalyticsService from './analytics.service'; | |
angular.module('app', []) | |
.service('Analytics', AnalyticsService); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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