When I do a $http.post
in AngularJS with a object like:
{ name: '232', id: '3434', $type: "API.Models.Fields.ValuesList, API" }
with the signature:
$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 ;) ?
UPDATE: ANGULAR >= 1.3 NOW DOES NOT REMOVE THE $ ATTRS.
Yes, Angular strips dollar-prefixed properties when sending data over $http
service.
$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).
Quick workaround is to stringify the data manually (using JSON.stringify), before passing it on to $http
:
$http.post('/api/path', JSON.stringify(model));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With