Angular JS success callback

后端 未结 3 1781
萌比男神i
萌比男神i 2021-01-28 08:09

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

3条回答
  •  一整个雨季
    2021-01-28 09:04

    factory does not need to return a promise.I mean that depends on how you manage your factory and controllers and how you are going to resolve it.

    your factory does not return a promise but resource, so it should be resolved in your controller. your update method in controller should be like this :

        $scope.UpdateEmp = function () {
        var empl = $scope.Employee;
        empFactory.empUpdate.update({ EmpID: $routeParams.EmpID, empval: empl }, function (successResponse) { // update method in my resource uses $resource
            $location.path('/EmpList'); //redirect to list
        },function (error) { 
         // do something on error callback
        });
    

    read about angularjs resource angularjs docs about $resource

提交回复
热议问题