<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>
当用户点击复选框时,它应该触发点击事件进行一些更新。然后,我希望复选框返回到正常状态(未选中状态)。
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;
}
}]);
$ scope.statusChecked.isChecked的值变为true但不取消选中该复选框。
有人可以帮助我吗?
答案 0 :(得分: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();
}
你说ng-true-value = true,但是当statusChange函数改变为&#34; YES&#34;价值不是&#34;真&#34;值。
答案 1 :(得分:1)
您应该使用ng-checked
。
示例:
<input type="checkbox" ng-click="statusChange()" ng-checked='statusBox.isChecked' ng-true-value="true" ng-false-value="false">nur unbeantwortete</li>
它将检查truthy值并取消选中falsy值。