var app = angular.module('maplePointApp', []); app.config(["$httpProvider", function ($httpProvider) { //更改 Content-Type $httpProvider.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded;charset=utf-8"; $httpProvider.defaults.headers.post["Accept"] = "*/*"; $httpProvider.defaults.transformRequest = function (data) { //把JSON數據轉換成字符串形式 if (data !== undefined) { return $.param(data); } return data; }; }]) app.controller('myCtr', function($scope,$http) { $scope.initIndex = function () { $http({ method : "post", url : "${REQ}/maple/point", data : { "id" : 123 } }).success(function(rs) { console.log(rs) $scope.dataList=rs; }).error(function(rs) { }); } });
angularjs post 後臺 取不到值,修改contentTye 可以解決
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.