lundi 23 mars 2015

If-statement and object's $id inside of it

So I have the following for-loop, and If function inside:



for (var i = 0, k = messages.length; i<k; i++){
if (messages[i].$id = $stateParams.recipientId && found) {
$scope.message.push(messages[i]);
found = false;
}
}


My message object has following structure:


enter image description here So inside the loop the following happens: if function checks it the $id of the message object is the same as the $stateParams, and then it passes the message to the different variable, and then it should stop. However, what happens inside the If is weird for me: the messages[i].$id changes from "12345" to just "true". Why does this happen, and is there any way to find any way to fix this?


Thanks!


Aucun commentaire:

Enregistrer un commentaire