Avoid this Anti-Pattern
var myDeferred = $q.defer(); $http(config).then(function(res) { myDeferred.resolve(res); }, function(error) { myDeferred.reject(error); }); return myDeferred.promise;
There is no need to manufacture a promise with $q.defer
as the $http service already returns a promise.
//INSTEAD
return $http(config);
Simply return the promise created by the $http service.