AIA.factory('AdminService', function ($http, $q) { return { SendAdminAccessRequestMail: function (userInfo) { var deferred = $q.defer(); $http.post('/API/api/AdminAccess', userInfo, { headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { console.log('success'); deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(status); }); return deferred.promise; } } });