AngularJS $ http服务中的encodeURIComponent [英] encodeURIComponent in AngularJS $http service
本文介绍了AngularJS $ http服务中的encodeURIComponent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是AngularJS的新手,正在尝试学习绳索.
我正在使用下面的代码行(请您放心使用)将 item
信息发送到服务器方法,该服务器方法随后将发送包含所述 item
.
$ http.post('/EmailItem',item);
我的问题是, item
的属性值在发送之前是否先经过 encodeURIComponent
?
奖励问题:是否有更好的方法来发表帖子? $ resource
看起来比我需要的更多...?
解决方案
您不需要对属性进行编码, $ http
可以: 解决方案
You don't need to encode the properties, $http
does: https://github.com/angular/angular.js/blob/master/src/ng/http.js#L758
As to the way of doing it.. This looks fine. You can switch to $resource
if have an object that needs a couple of REST things on the server, but $http
works fine in simple situations.
这篇关于AngularJS $ http服务中的encodeURIComponent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文