1

下面是我的 $http 调用。角度是否有一些功能,如成功之前 所说的,它将在实际 $http 调用之前执行

 $http.post(postUrl, $scope.tempData, {
        }).success(function(response) {

                alert(response); 

       }).error(function (errorCode) {

           alert(errorCode); 
       }
           );
4

1 回答 1

1

Does angular has some function like success say before which will execute before actual $http call.

Quick answer: No.

But you can implement this module in factory or provider and implement any logic you want.

Here is example:

.factory('ajax_post', ['$http', function(_http) {

    var path = 'src/php/data.ajax.php';

    return{
        init: function(jsonData){

            // do logic here


            var _promise= _http.post(path, 
                jsonData
                ,{
                    headers: {
                        'SOAPActions': 'http://schemas.microsoft.com/sharepoint/soap/UpdateListItems'
                    }
                }
                );            
            return _promise; 
        }

    }   
}]);
于 2013-10-26T07:35:59.803 回答