We have managed to create the script below to remove any duplicate strings from an array. However, it is important that we keep the order of the array for when angular loops through them on an ng-repeat. In addition, we want the remaining elements to keep the same index.
scope.feedback = _.map(_.pluck(item.possibleAnswers, 'feedback'), function (element, index, collection) {
return collection.slice(0, index).indexOf(element) === -1 ? element : '';
});
This code above works however we feel like there must be a more simple solution to our problem than this. Has anyone else had a similar problem and come up with a better solution?
See Question&Answers more detail:os