AngularJS ile "tic tac toe" bir sürümünü oluşturmaya ve olabildiğince minimal düzeyde çalışmaya çalışıyorum. Sorunum için tek çözüm, her düğmeye benzersiz bir kimlik atamaktır (f + i).Bir ifadeyi değerlendirerek özel bir HTML kimliği nasıl oluşturulur
HTML
<table>
<tr ng-repeat="f in [5,10,15]">
<!-- numbers chosen for unique combos-->
<td ng-repeat="i in [0,1,2]">
<button ng-click="toTrue()" >
<div >
{{getXO()}}
</div>
</button>
</td>
</tr>
</table>
JavaScript
$scope.XObool=false;
$scope.toTrue = function() {
if(!$scope.XObool){
$scope.XObool=true;
}
else if($scope.XObool) {
$scope.XObool=false;
}
};
$scope.getXO = function(){
if($scope.XObool){
return 'X';
}
else {
return 'O';
}
};