当我做了 $ 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移除属性
发布评论