It is not clear to me the best practice for maintaining $scope of objects when making calls to a RESTful API. The problem I'm having is working with a Schema that has nested sub arrays, see below.
Is it best practice when making RESTful API call to expect a full JSON document in the response to update the $scope, or should I be able to maintain $scope on the client with Angular with nothing more than a http response code (ie 200)? It makes sense when making updates to the user
object, but when I need to update profiles
or favorites
sections of the document, I'm just passing that portion of the document to the API and getting an http reponse code back, and my $scope doesn't reflect with the change, especially when pushing or pulling over PATCH route.
{
"_id" : ObjectId("558d53eebdd9804820090fa1"),
"name" : "Frank",
"email" : "Frank@FrankTheTank.com",
"profiles" : [
{
"avatar" : "div-male",
"age" : "35",
"gender" : "Male",
"profilename" : "Oly Lifter",
"_id" : ObjectId("558d5404bdd9804820090fa2"),
"favorites" : [
{
"name" : "Power Clean"
},
{
"name" : "Hang Clean"
},
{
"name" : "Clean and Jerk"
}
],
"createdAt" : ISODate("2015-06-26T13:30:44.661Z")
}
],
"createdAt" : ISODate("2015-06-26T13:30:22.884Z"),
"role" : "user"
}