Looking to modify the way I am sending a POST request with nested child objects. Here is the current format:
{
"title": "sample string 2",
"comment": "sample string 5",
"child": {
"name": "sample string 2"
},
"children": [
{
"name": "sample string"
},
{
"name": "sample string"
}
]
}
Currently, I am sending this:
{
"title": "sample string 2",
"comment": "sample string 5"
}
using this in the controller:
vm.product = new Product();
vm.product.title = "My title";
vm.product.comment = "my comment";
Here is the resource factory being used:
myApp.factory('Product', function ($resource) {
return $resource('http://api.com/api/product/:id', { id: '@id' }, {
update: {
method: 'PUT'
}
});
});
Although the current setup works, I am looking to adjust the code to include child objects. I have tried:
vm.product.child.name = "my new child"
But unfortunately, it has not been successful. Any suggestions on how to implement this nested object structure?