Skip to content

Instantly share code, notes, and snippets.

@jonocairns
Created April 30, 2015 20:54
Show Gist options
  • Save jonocairns/6d9cf0d3c53acf16904e to your computer and use it in GitHub Desktop.
Save jonocairns/6d9cf0d3c53acf16904e to your computer and use it in GitHub Desktop.
'use strict';
module app.services {
export interface IExampleService {
get<T>(): T
}
export class ExampleService implements IExampleService {
constructor(private $http: ng.IHttpService) {
}
get(): ng.IPromise<string> {
return this.$http.get('/api/example')
.then((response: ng.IHttpPromiseCallbackArg<string>): string => {
return response.data;
});
}
}
function factory($http: ng.IHttpService): IExampleService {
return new ExampleService($http);
}
factory.$inject = [
'$http'
];
angular
.module('app.services')
.factory('app.services.ExampleService', factory);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment