AngularJS $ http.post移除属性

编程入门 行业动态 更新时间:2024-10-12 05:44:46
本文介绍了AngularJS $ http.post移除属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我做了 $ http.post 在AngularJS像一个对象:

When I do a $http.post in AngularJS with a object like:

{ name: '232', id: '3434', $type: "API.Models.Fields.ValuesList, API" }

与签名:

$http.post('api/records', model);

在 $类型属性被删除的镀铬流量监听每次无论价值。

the $type attribute is removed everytime on the chrome traffic listener no matter the value.

有一些秘密$卸妆;?)

Is there some secret $ remover ;) ?

更新:ANGULAR> = 1.3现在已经不删除$ ATTRS

推荐答案

是,在 $ HTTP 服务发送数据时角条以美元prefixed属性。

Yes, Angular strips dollar-prefixed properties when sending data over $http service.

$ HTTP服务中使用 angular.toJson 串行化的方法对象JSON字符串。此法条因为角度使用这个符号内部(如实例方法 $保存适用于所有 ngResource 对象)与领先的$字符属性

$http service serialises objects to JSON string using angular.toJson method. This method strips properties with leading $ characters because angular uses this notation internally (e.g. instance method $save is available on all ngResource objects).

快速的解决办法是将它传递给之前手动字符串化数据(透过JSON.stringify), $ HTTP :

Quick workaround is to stringify the data manually (using JSON.stringify), before passing it on to $http:

$http.post('/api/path', JSON.stringify(model));

更多推荐

AngularJS $ http.post移除属性

本文发布于:2023-10-10 09:46:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1478328.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:移除   属性   AngularJS   http   post

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!