var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.f1 = function(){
$scope.half = $scope.pany.length / 2;
if($scope.ctrack < $scope.half){
document.getElementById(buttonid).style.color = "green";
}
else
{
alert("You have no more letters to flip, please make your guess NOW!");
$scope.wanna();
}
$scope.ctrack++;
}
$scope.f2=function(){
alert("There is nothing in this box.");
}
$scope.game = function(){
while($scope.boxcount<=99)
{
if($scope.boxcount==50){
$scope.tab = $scope.tab + "</tr><tr>";
}
if($scope.boxcount < $scope.size)
{
$scope.tab = $scope.tab + "<td><button class='c1' id='"+$scope.boxcount+"' ng-click='f1("+"'"+$scope.boxcount+"'"+")';>"+$scope.pany.charAt($scope.boxcount)+"</button></td>";
}
else
{
$scope.tab = $scope.tab + "<td><button class='c2' id='"+$scope.boxcount+"' ng-click='f2();' ></button></td>";
}
$scope.boxcount++;
}
$scope.tab = $scope.tab + "</table>";
document.getElementById('tabcells').innerHTML = $scope.tab;
}
如果单击按钮,则不会执行f1()函数