I am currently dealing with a table that has been created using ng-repeat for rows and columns.
ng-model="tableValues[row][column]"
The values for row and column are obtained from ng-repeat. The data in the table consists of dropdowns, which I want to populate from a list of values.
However, when I try to write values to the ng-model from the controller, it ends up overwriting existing values for columns.
var x ={};
for(objData){
row = objData[i]["row"];
column = objData[i]["column"];
value = objData[i]["value"];
x[row]={};
x[row][column]=value;
vm.tableValues=x;
}
//objData is an array of objects where each object contains the value along with its corresponding row and column.
Although this code creates the correct JSON structure, it keeps overwriting values for columns.
{"r1":{"c1":"v1"},"r2":{"c2":"v2"},"r3":{"c2":"v2"}}
what I actually need is:
{"r1":{"c1":"v1","c2":"v2","c3":v3,"c4":"v4"},
{"r2":{"c1":"v1","c2":"v2","c3":v3,"c4":"v4"}.......}
and so on..
Instead of replacing previous column values when putting them inside a row JSON by comma, I want all column values to be retained.