Created
April 30, 2015 20:54
-
-
Save jonocairns/6d9cf0d3c53acf16904e to your computer and use it in GitHub Desktop.
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
'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