-3

Suppose my JSON is:

{
  "todo" : "Dinner",
  "user" : [
    {
      "name" : "",
      "password" : ""
    }
  ],
  "notes : "some notes"
}

And I want to formulate the object from that JSON.

So in angularjs, first I can do the following to formulate the user array:

userArray = [{
                name: 'myname',
                password: 'password'
            }];

And my object without userArray is as follows:

var object = {};
object.todo = "Dinner";
object.notes = "some notes";

Now how to add userArray to this object to get the complete object?

My God
  • 22,686
  • 26
  • 99
  • 179

1 Answers1

0

Just set the array to your scope object in the controller. Angular has nothing to do with this. Its plain JavaScript.

$scope.object.user = userArray;
Anik Islam Abhi
  • 24,762
  • 8
  • 55
  • 78
Dennis Nerush
  • 5,063
  • 5
  • 24
  • 32