嘿,实际上我做了一个 html 页面,其中有两个部分,当我点击第一部分时,数字会增加,当我点击第二部分时,第二部分的数字会增加。我为此使用了 javascript。现在我在每个页面的底部做了一个按钮。我想要当我点击那个按钮时数字应该减少我尝试了很多方法但是每次我失败当你运行 snipet 点击开始按钮你会看到我想要的减号按钮当我点击那个分数应该减少
angular.module('scoreKeeper', []).
controller('score', ['$scope', function ($scope) {
$scope.gameInfo = {
gameStarted: false,
servesSinceSwitch: 0,
scoreSwitchMode: 0,
numberOfPlayers: 2 };
$scope.team1 = {
name: "Team 1",
score: 0,
serving: false };
$scope.team2 = {
name: "Team 2",
score: 0,
serving: false };
$scope.player1 = {
name: "P1",
serving: true };
$scope.player2 = {
name: "P2",
serving: true };
$scope.player3 = {
name: null,
serving: false };
$scope.player4 = {
name: null,
serving: false };
$scope.startGame = function () {$scope.gameInfo.gameStarted = true;};
$scope.players = function (n) {
$scope.gameInfo.numberOfPlayers = n;
if (n == 2) {
$scope.player3.name = null;
$scope.player4.name = null;
} else {
$scope.player3.name = "P3";
//$scope.player3.serving = true;
$scope.player4.name = "P4";
//$scope.player4.serving = true;
}
};
$scope.addPoint = function (i) {
// Start the game, give the Serving class to the person who won the rally
if (!$scope.team1.serving && !$scope.team2.serving) {
$scope['team' + i].serving = true;
$scope.footer.message = "Game on!";
} else {
// Increment the player's score, how many serves since the last switch, and the highest current score
$scope['team' + i].score++;
$scope.gameInfo.servesSinceSwitch++;
$scope.gameInfo.highestScore = Math.max($scope.team1.score, $scope.team2.score);
慕田峪9158850
呼如林
相关分类