如何在不使用jQuery的情况下序列化一个对象$.param
?如何使用angularjs序列化对象
我想下面的对象:
var user = {username: 'ronald.araujo', password: '123456',};
有以下的输出:
username=ronald.araujo&password=123456
有什么建议?记住我会用Angularjs或纯Javascript来做到这一点。
编辑:
我现在用的动词 “保存”($资源)的angularjs。我怎么能设置标题“application/x-www-form-urlencoded”并且序列化?
你的意思是将它序列化为'application/x-www-form-urlencoded'格式?这里有一个简单的lib可用 - https://github.com/iambumblehead/form-urlencoded – Phil 2015-04-01 02:50:10
可能的重复[如何使用$ http在AngularJS中POST urlencoded表单数据?](http://stackoverflow.com/questions/ 24710503/how-do-i-post-urlencoded-form-data-with-http-in-angularjs) – Phil 2015-04-01 02:52:53
在Angular afaik中没有内置的工具。但你为什么要这么做?您可以发送任何GET请求,而无需手动将数据添加到URL中。 – floribon 2015-04-01 02:55:49