try and think of what the information will be on the page, then design your model to that... you can have larger objects living back in some service if you need to and then you can extract smaller parts and serve it out the controller.
if you get used to db's like mongo you will start to think in very large objects and it is easier to work with in many cases.
in your example i would just pass comments as an object literal inside an array:
var article = {
text: "this is my article text blah blah",
date: "some timestamp",
author: "joe cool",
comments: [
{ text: "my first comment", author: "will smith" },
{ text: "my first comment", author: "will smith" },
]
};
jamey
On Monday, September 17, 2012 2:33:24 PM UTC-4, dreamer wrote:
I am trying to build and post($http) some complicated multi nested Json and I just want to know how you guys are doing..
Is there some better way to design the model? what if all below stuffs have to be sent together?
$scope.obj1 =
{what:'learn angular', done:true, comments:''}
{what:'build an angular app', done:false, comments:''}];
//Nested to obj1
$scope.comments =
{col1:'test', col2:'test'}
{col1:'test1', col2:'test2'}];
$scope.obj2 =
{who:'me', when:'now'}
{who:'you', when:'yesterday'}];