0
<ul class="quiz-footer">
            <li><a class="nav-link" href="#">Home</a></li>
            <li><a class="nav-link" href="#">Glossar</a></li>
            <li><a class="nav-link" href="#">Suche</a></li>
            <li><a class="nav-link" href="#">Lesezeichen</a></li>
            <li class="nav-item">Frage:</li>
                <li><a class="nav-link" href="#"><<</a></li>
                <li><a class="nav-link" href="#" ng-click="decrementOne()"><</a></li>
                <li><a class="nav-link" href="#" ng-click="incrementOne()">></a></li>
                <li><a class="nav-link" href="#">>></a></li>
            <li><input type="checkbox" ng-click="statusChange()" ng-model='statusBox.isChecked' ng-true-value="true" ng-false-value="false">nur unbeantwortete</li>
            <li><a class="nav-link weiter-link quiz-anzeigen">Lösung anzeigen</a></li>
</ul>

When user clicks on the checkbox it should trigger the click event to some update. Then, I want checkbox to go back to its normal state (unchecked state).

app.controller("QuizController", ['total', '$scope', '$http', function (total, $scope, $http) {
    $scope.statusBox= { isChecked: false };

$scope.statusChange = function () {
        $scope.quizzes[$scope.count].exclude= true;
        $scope.statusBox.isChecked = "YES";
        $scope.incrementOne();
    }

    $scope.excludeQuestion = function () {
    }

    $scope.incrementOne = function () {
        $scope.disableStatus = false    ;
            $scope.selection = [];
            $scope.three = "front";
            $scope.count = $scope.count + 1;
        $scope.statusBox.isChecked = false;
    }
}]);

The value of $scope.statusChecked.isChecked becomes true but it does not uncheck the checkbox.

Can anyone here please help me?

1
  • I won't put up a separate answer for this but your $scope.quizzes[$scope.count].exclude= true; gives an error and the $scope.incrementOne(); function is not even fired. Commented May 2, 2016 at 10:23

2 Answers 2

1
    $scope.statusBox= { isChecked: false };

   <li><input type="checkbox" ng-click="statusChange()" ng-model='statusBox.isChecked' ng-true-value="true" ng-false-value="false">nur unbeantwortete</li>

     $scope.statusChange = function () {
        $scope.quizzes[$scope.count].exclude= true;
        $scope.statusBox.isChecked = "YES";
        $scope.incrementOne();
    }

You said that ng-true-value = true , but when statusChange function it's change for "YES" value is not "true" value.

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

Comments

1

You should use ng-checked.

Example:

<input type="checkbox" ng-click="statusChange()" ng-checked='statusBox.isChecked' ng-true-value="true" ng-false-value="false">nur unbeantwortete</li>

It will checked for truthy value and unchecked for falsy value.

See doc

1 Comment

When I changed to ng-checked it does not updated everytime.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.