user2948105 user2948105 - 4 months ago 18
JSON Question

angular add/update json object from user input both attribute and value

I am able to get both attribute name and value from user input

{{attribute}} and {{value}}

how do i add these to an existing json object

$scope.items ={
name: peter,
age: 16,
{{attribute}}: {{value}}


You could use bracket notation.

$scope.items[$scope.attribute] = $scope.value;