When receiving an array of data from the server in AngularJS, I need to dynamically update the $scope.
The initial value is :
$scope.form = {};
I would like to update it dynamically as follows:
$scope.form = {"firstname" : "Alex"};
Both 'firstname' and 'alex' should be updated using an array like this:
sent.then(function(result) {
angular.forEach(result.data.test, function(value, key){
// ** something like this, but it doesn't work :
var form_child = "{" + value.FieldName + ":" + value.FieldValue "}";
$scope.form = form_child;
});
});
How can I achieve line **?