Created
September 2, 2016 01:09
-
-
Save IEvangelist/956a05cdfdeeccf975414ca47f4c198c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module ExampleModule { | |
export class ExampleService implements IExampleService { | |
static $inject = ["$http", "$q"]; | |
private $http: ng.IHttpService; | |
private $q: ng.IQService; | |
constructor($http: ng.IHttpService, | |
$q: ng.IQService) { | |
this.$http = $http; | |
this.$q = $q; | |
} | |
public getFooBars(): ng.IPromise<FooBar[]> { | |
var deferred = this.$q.defer<FooBar[]>(); | |
this.$http | |
.get("api/foobar") | |
.success((data) => { | |
deferred.resolve(data); | |
}) | |
.error((error) => { | |
console.log("An error occurred when requesting api/foobar.", error); | |
deferred.reject(error); | |
}); | |
return deferred.promise; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment