I defined a nested loop in angular2 to display a form. Now I want to process the data entered by the user. The code is as follows
this.data = value;
for (var i=0;i<this.questionlist.length;i++){
this.questionId[i]=this.questionlist[i].id;
this.tempdata = this.questionlist[i].ans;
for(var j=0;j<this.tempdata.length;j++){
console.log(this.data[this.questionId[i]].(this.tempdata[j]))
}
}
The names of each array and the arrays nested inside are the methods of obtaining the data before. Generally speaking, they are not fixed. Now I want to read out each value, so the question is, what should I do? How can I read the nested value where the last this.tempdata[j]
is the name?
I’ve been thinking about it for a long time and checking it out for a long time, but I can’t find any solution_(:з ∠)_
Can you write a mock of your data? It’s very abstract. Look at the data and tell everyone which one and which layer you want to get. It will be easier to understand
Is this what you want
Is this how to take the this.tempdata[j] attribute of this.questionId[i] under this.data (it is still an object here)?