I'm getting an array of data from server and going to update the $scope
in angularJS.
The initial value is :
$scope.form = {};
I want to update dynamically like this:
$scope.form = {"firstname" : "Alex"};
both firstname
and alex
must update by 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 should I do line ** ?
Use array syntax :
$scope.form[value.FieldName] = value.FieldValue;