Created
August 24, 2014 08:06
-
-
Save wullemsb/f6bf19c70d6732d45ee9 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
var baseService={ | |
$http: {}, | |
$q: {}, | |
rootUrl: 'http://localhost/api/', | |
urlSuffix:'', | |
get: function () { | |
var defer = this.$q.defer(); | |
this.$http.get(this.rootUrl + this.urlSuffix) | |
.success(function (response) { | |
defer.resolve(response.value); | |
}) | |
.error(function (err) { | |
defer.reject(err); | |
}); | |
return defer.promise; | |
} | |
}; | |
function ProductsService($http, $q) { | |
this.$http = $http; | |
this.$q = $q; | |
this.urlSuffix = 'Products'; | |
} | |
angular.extend(ProductsService.prototype, baseService); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment