Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Created August 24, 2014 08:06
Show Gist options
  • Save wullemsb/f6bf19c70d6732d45ee9 to your computer and use it in GitHub Desktop.
Save wullemsb/f6bf19c70d6732d45ee9 to your computer and use it in GitHub Desktop.
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