var app = angular.module("myApp", [], function ($httpProvider) {

$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
/**
* The workhorse; converts an object to x-www-form-urlencoded serialization.
* @param {Object} obj
* @return {String}
*/
var param = function (obj) {
var query = '', name, value, fullSubName, subName, subValue, innerObj, i; for (name in obj) {
value = obj[name]; if (value instanceof Array) {
for (i = 0; i < value.length; ++i) {
subValue = value[i];
fullSubName = name + '[' + i + ']';
innerObj = {};
innerObj[fullSubName] = subValue;
query += param(innerObj) + '&';
}
}
else if (value instanceof Object) {
for (subName in value) {
subValue = value[subName];
fullSubName = name + '[' + subName + ']';
innerObj = {};
innerObj[fullSubName] = subValue;
query += param(innerObj) + '&';
}
}
else if (value !== undefined && value !== null)
query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&';
} return query.length ? query.substr(0, query.length - 1) : query;
}; // Override $http service's default transformRequest
$httpProvider.defaults.transformRequest = [function (data) {
return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
} ]; });
   app.controller("addController", ["$scope", "$http", function ($scope, $http) {

             $scope.save = function () {
if ($scope.myForm.$valid) {
var data = { "name": $scope.txtname, "address": $scope.txtaddress, "phone": $scope.txtphone, "zipcode": $scope.txtzipcode, "isdefault": $scope.cbxisdefault };
$http.post("AddUserAddress", data).success(function (result) {
alert(result);
});
}
}
} ]);

只有配置了$http的默认文档类型才能再后台用Request来获取提交的参数

Content-Type

随机推荐

  1. phpcms插件开发初步规范

    phpcms公用库函数原型 (一)./include/global.php 中的函数可在phpcms的任何一个程序中调用,下面是各函数的原型及用法. message($alert,$goback='' ...

  2. phpEXCEL操作全解

    phpExcel中文帮助手册,列举了各种属性,以及常用的操作方法,难得是每一个都用实例加以说明,希望对大家有所帮助. phpExcel中文帮助手册,不可多得的好文章,供大家学习参考. 1.设置exce ...

  3. 网址测速JS

    /*.route_nav li a:hover{background: #3c7f84 url(title.png) no-repeat;border-color:#84a3a5;}*/ .route ...

  4. Ubuntu等Linux系统清除DNS缓存的方法

    buntu等Linux系统清除DNS缓存的方法 直接说方法: 如果系统下有nscd,那么就直接 sudo /etc/init.d/nscd restart 如果没有也没关系,网上接受的方法大都是 su ...

  5. Filter及FilterChain的使用详解

    原文地址:http://blog.csdn.net/zhaozheng7758/article/details/6105749 一.Filter的介绍及使用 什么是过滤器? 与Servlet相似,过滤 ...

  6. PHP之mysql笔记

    1:在php中提供了两个用于连接MySQL数据库服务器的函数. (1)int mysql_connect(hostname[:port][:/path/to/socket],user,pass). ( ...

  7. JSON stringify and parse

    来源 : http://javascript.ruanyifeng.com/stdlib/date.html //解析json也可以传入一个方法, 基本上和stringify差不多,不过是逆序的, 要 ...

  8. Spring MVC 如何防止XSS、SQL注入攻击

    在Web项目中,通常需要处理XSS,SQL注入攻击,解决这个问题有两个思路: 在数据进入数据库之前对非法字符进行转义,在更新和显示的时候将非法字符还原 在显示的时候对非法字符进行转义 如果项目还处在起 ...

  9. 【HDOJ】1341 Simple Computers

    注意PC要与31. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 40 ...

  10. xcode安装

    Xcode5.1默认不支持iOS5版本的模拟器开发调试,在OS X Mavericks(10.9.x)下默认只能支持iOS6.1及以上版本的模拟器,在OS X Mountain Lion(10.8.x ...