I feel the need to clarify this for anyone else finding this question.
Passing $scope.company
passes the JS object that is company
that does not include the name of the scope variable itself:
{
name: 'Test Company',
owner: {
name: 'Test Owner'
}
}
The server will see this as a POST variable named name
that is a string with value 'Test Company' and another variable named owner
that is an array with an index named name
with value of 'Test Owner`
In PHP it would be this:
$_POST['name']; // would = 'Test Company'
$_POST['owner']; // would = array('name'=>'Test Owner')
If you want it to be an array of properties on the server side referred to as company
then you need to encapsulate $scope.company
in a JS object itself with a property titled "company":
$scope.company = {
company: {
name : 'Test Company',
owner : {
name : 'Test Owner'
}
}
};
Now on the server side you'll find this:
$_POST['company']; // would = array('name'=>'Test Company','owner'=>array('name'=>'Test Owner'))