I display a list, each item includes an array of ids that reference other documents (mongodb). When the user clicks on an item I want to populate the array with the actual documents (= replacing the ids with the corresponding object).
My problem is that the data is not applied to the correct place in the array once the requests finish. Probably the index that I hand over in the callback function is increased as the for loop marches on. By the time the request is ready, the for loop likely already finished so the result gets attached to the end of the array instead of its original position. I tried deep copying the index with angular.copy() although I believe that should not be necessary. I am not even sure if int is an object or a flat datatype, a small Google research yielded no clear answer to that.
I was able to re-create the problem in a plunkr.
I encountered a similar problem before but was able to work around it but this time I am not sure how to deal with this problem. Any hints?