Angular JS:在页面刷新

时间:2017-02-22 14:13:16

标签: angularjs

我有一个输入框,可以接受在使用ng-disabled

输入正确值时立即禁用的字符

然而,当我移动到下一个项目并上一个按钮时,页面会刷新

= 4)&&

我需要能够将问题的索引放入缓存

localStorage.setItem();

控制器:

$scope.initializeGame = function() {

    $scope.score = (localStorage.getItem("token")) ? parseInt(localStorage.getItem("token")) : 0;
    $scope.scoreValue = $scope.score
    $scope.noOfTries = 0;
    $scope.original = $scope.pageTitle;
    $scope.guess = null;
    $scope.deviation = null;

    $scope.verifyGuess = function() {
        $scope.deviation = $scope.original - $scope.guess;

        $scope.noOfTries = $scope.noOfTries + 1;
        $scope.falseAnswer = $scope.deviation != 0;
        if ($scope.deviation == 0 && $scope.noOfTries == 1) {

          $scope.scoreValue = parseInt($scope.score, 10) + 1;
          var token = $scope.scoreValue;

          localStorage.setItem("token", token);

};

0 个答案:

没有答案