user2948105 user2948105 - 1 month ago 5
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;