What is the best practices when dealing with nested resources with restangular? i.e.
Restangular.one("accounts", 1).one("projects", 1).get().then(function (project) {
project.getList("proofs").then(function(proofs){
project.proofs = proofs;
_.each(proofs, function(proof){
proof.comments = proof.getList("comments");
});
});
$scope.project = project;
});
This would allow me to access each inside the view nicely.
<li ng-repeat="proof in project.proofs">Total: {{proof.comments.length}}</li>
If I then want to make a update to the project, it would then send EVERYTHING to the projects REST endpoint (including all proofs, and all proofs.comments).
project.name = 'New Name!';
project.put();
This makes me think that I must be implementing something wrong, and there muse be a better way of dealing with it?
Short of defining everything straight to individual $scope's with something like this (not tested)? i.e.
Restangular.one("accounts", 1).one("projects", 1).get().then(function (project) {
project.getList("proofs").then(function(proofs){
$scope.projectProofs = proofs;
_.each(proofs, function(proof){
$scope.proofComments[proof.id].push(proof.getList("comments"));
});
});
$scope.project = project;
});
What is the suggested best practice for this?