Angular JS 1.X 接口拿不到 http post 请求的数据

app上加上配置相关的代码即可

var myApp = angular.module('myApp',[]);
    myApp.config(function($httpProvider){
        $httpProvider.defaults.transformRequest = function(obj){
            var str = [];
            for(var p in obj){
                str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
            }
            return str.join("&");
        }
        $httpProvider.defaults.headers.post = {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });

 

posted @ 2018-09-19 17:52  凌雨尘  阅读(307)  评论(0编辑  收藏  举报