Adding Fields/values To An Object
I am trying to figure out a way to add field names and values to an object. for example I hav ethe following... $scope.product = { 'Requirements': [ {
Solution 1:
You can use baces passing index like an array:
$scope.product["Requirements"][0]["Term"] = 36
$scope.product["Requirements"][0]["Quantity"] = 1
you can also do in this way
$scope.product["Requirements"][0].Term = 36
$scope.product["Requirements"][0].Quantity = 1
and also...
$scope.product.Requirements[0].Term = 36
$scope.product.Requirements[0].Quantity = 1
What do you need to understand is how to go through a javascript object using braces [] or point . Take a look at this link
Post a Comment for "Adding Fields/values To An Object"