Reputation: 590
I have a button that I want to hide when the array $scope.game.players.players
contains specific value.
button(ng-click="", ng-hide="ImPlaying()") Play
The function ImPlaying()
checks the condition and return a boolean
$scope.ImPlaying = function(){
$scope.game.players.playerExist($scope.user.socketID, function(exist){
console.log(exist);
return exist;
});
}
exist
change value but the button is always shown
But when I replace the function $scope.game.players.playerExist()
by its code everything works as expected.
$scope.ImPlaying = function(){
for (var i = 0; i < $scope.game.players.players.length; i++) {
if($scope.game.players.players[i]){
if($scope.game.players.players[i].socketID == $scope.user.socketID){
return true;
}
}
};
return false;
}
What's wrong with the first function ?
Upvotes: 0
Views: 85
Reputation: 2584
You're missing return statement in ImPlaying function
$scope.ImPlaying = function(){
return $scope.game.players.playerExist($scope.user.socketID, function(exist){
console.log(exist);
return exist;
});
}
Upvotes: 2