I m reaching out to you to get assistance on the $promise issue with AngularJS.
Here is the documentation information on $resource and it will be applicable to $http as
First i see a design problem, your factory shouldn't return resources, should return promises,
myservice.factory('empFactory', function ($resource) {
var employeeResource = $resource('../../Employee/GetEmployee/:EmpID', { EmpID: '@EmpID'}, {show: { method: 'GET' } }),
updateResource = $resource('../../Employee/PutEmployee/:EmpID', { EmpID: '@EmpID', empval: '@empl' }, { update: { method: 'PUT', isArray: true } }),
deleteResource = $resource('../../Employee/DeleteEmployee/:EmpID', { EmpID: '@EmpID' }, { del: { method: 'DELETE', isArray: true } }),
createResource = $resource('../../Employee/CreateEmployee', { empval: '@empl' }, { create: { method: 'POST', isArray: true } });
return {
getEmployee: function(id){
return employeeResource.get({EmpID: id}).$promise;
},
updateEmployee: function(){
return updateResource.update(...).$promise;
}
};
});
I think that the problem is that you are calling
$scope.Employee = empFactory.employee.show({ EmpID: $routeParams.EmpID });
This returns a resource right now, so you are not technically obtaining the employee anywhere. Is not very clear where is the error, are you trying to execute several resource request in parallel? if that's it use $q.all([asyncCall1,asyncCall2,...]).spread(function(r1, r2, ...) {...});
Regards