0

I have an Input box that accepts characters which gets disable instantly when the correct value is entered using ng-disabled

However when I move to the next item and prev the next button the page refreshes

= 4) &&

I need to be able to place the index of the question into Cache

localStorage.setItem();

Controller:

$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);

};
3
  • do you not see the item in localStorage? Commented Feb 22, 2017 at 14:24
  • I was more after the method of from a returned list objects from an ng-repeat statement how do I record using the index number of the object that it has been answered correctly e.g. into local Storage or any other method to sustain that it has been answered. Commented Feb 22, 2017 at 14:32
  • are you using ui-router? because if you were before the next page was resolved, you could call a function to check if the next expected id was answered in your local and then if so, set it. Commented Feb 22, 2017 at 14:39

1 Answer 1

1

From your html, pass $index to the method being called. This will give you the index of the particular question for which the method is called.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.