如何使用ngResource模块具有角发送的X WWW的形式urlen codeD数据? [英] how to send x-www-form-urlencoded data using ngResource module with angular?
本文介绍了如何使用ngResource模块具有角发送的X WWW的形式urlen codeD数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
家居生活的称号。
在生产角度的资源时:
myModule.factory('MyResource', ['$resource', function ($resource) {
return $resource('api/MyResource/:id');
}]);
和使用中的控制器:
MyResource.save({att: att, att2: att2});
服务在 JSON
神器发送数据提前到服务器。
the Service sends the data in a json
artifact ahead to the server.
我需要在发送数据的X WWW的形式urlen codeD
形状。
在哪里修改我的code,以解决?
Where ought I modify my code to resolve that ?
推荐答案
我终于找到了自己:
在定义资源和相关的指令,头参数来在手。
When defining a resource and the associated instruction, the "headers" parameter comes in hand.
myModule.factory('MyResource', ['$resource', function ($resource) {
return $resource('api/MyResource/:id', {}, {
save: { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
});
}]);
这篇关于如何使用ngResource模块具有角发送的X WWW的形式urlen codeD数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文