Sevensnake
Sevensnake

Reputation: 119

AngularJS not parsing data correctly in foreach

For some reason I amfiltering and my data is returning multiply times. for example if I have and ID return of 456, the data will return to row 4,5 and 6. Its driving me crazy. why is it looking at

Plnkr here

var question = $filter('filter')($scope.existingList, {
  QuestionID: item.QuestionID
});
console.log(question);
if(!item.answer && question.length>0 || !item.answer === item.answer){
  //console.log(question);
  item.answer = question[0].Response;
}

Upvotes: 0

Views: 43

Answers (1)

ShankarSangoli
ShankarSangoli

Reputation: 69905

Change the if condition to this if(!item.answer && question.length>0){

http://plnkr.co/edit/GEHRP4g1RyvwOPq9ntZq?p=preview

Upvotes: 1

Related Questions