I am facing an issue with adding data from the server to a JSON property and displaying it. I know that JSON only accepts primitive types, so how can I dynamically add data to a JSON property? For instance, in the code snippet below, I am trying to assign the value of diagramName to the "text" property.
ctrl.js
var diagramName = "";
$scope.data = resp.data;
angular.forEach($scope.data, function(diagram) {
diagramName = JSON.stringify(diagram.name);
console.log(diagram.name);
});
[{
"id": 1,
"text": "My Folder",
"children": [{
"id": 10,
"owner": "John Smith",
"text": diagramName,
"string": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>}]
}]