I am trying to create a comments section, similar to that of instagram whereby a list of comments is displayed, along side a user profile and usename for each comment.
I have a comments table in parse and a user table in parse, and so I have to perform a further query for each comment to get the profile picture link and username.
I am using angular to do this. I have a comments array to store all the commments, and I am pushing an object onto this array containing: - Username - profile picture - comment
var commentQuery = parseQuery.new('Comment');
commentQuery.equalTo("ID", id);
parseQuery.find(commentQuery)
.then(function(results) {
for(var i =0; i < results.length; i++){
var comment = results[i].get('comment');
var userQuery = parseQuery.new('_User');
userQuery.equalTo("objectId", results[i].get('userObject')[0].id);
parseQuery.find(userQuery)
.then(function(user) {
var commentObject = {
comment: comment,
username : '',
profile: ''
}
commentObject['profile'] = user[0].get('profile_picture')['_url'];
commentObject['username'] = user[0].get('liveUsername');
$scope.comments.push(commentObject);
})
}
})
What this then produces in my ng-repeat is a list, with the correct number of comments, however all the comments are the same!
If i print out the comments to the console as they are downlaoded, they are correct. It is at the object creation where things go wrong, and the same data is placed within all comment objects.

$scope.commentObjecttovar commentObject