Skip to content

Instantly share code, notes, and snippets.

@raribeiro
Created August 5, 2014 14:39
Show Gist options
  • Save raribeiro/a0eabe1467ad2b84d011 to your computer and use it in GitHub Desktop.
Save raribeiro/a0eabe1467ad2b84d011 to your computer and use it in GitHub Desktop.
Service with angularJS
app.factory('searchSchollService', ['$http', '$q', function($http, $q){
var searchSchollService = {};
searchSchollService.get = function(_param){
return $http.get(config.url.school_search(_param)).then(function(result_search){
if(typeof result_search.data === 'object'){
return result_search.data;
}else{
return $q.reject(result_search);
}
}, function(result_search){
return $q.reject(result_search);
});
};
searchSchollService.enableSchool = function(_school_id){
return $http({
method: "POST",
url: config.url.enable_school,
data: {
school_id: _school_id
}
});
};
return searchSchollService;
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment