// Check voted
var votes = res.data.votes;
if(votes.length == 0){$scope.like = true;}
votes.forEach(function(vote){
if(vote.userId === auth.profile.user_id) {
$scope.liked = true;
} else {
$scope.like = true;
}
});
I have written a code to check if the user has voted or not, but I'm having a small issue with the else statement:
using the following code, the $scope.liked works correctly, but the else statement only goes for the first.
How can I edit this, so he goes through all the votes, and if nothing is found, he displays the $scope.like