mardi 29 novembre 2016

AngularJs: Unable to uncheck checkbox when uncheck another checkbox

Got a problem, here the situation:
I want to uncheck the first checkbox when I uncheck the second checkbox.

Let say, by default both checkbox are checked. When I click second checkbox, I want the first checkbox to uncheck also.

HTML:

<ion-checkbox ng-model="firstCheckbox">First Checkbox</ion-checkbox>
<ion-checkbox ng-model="secondCheckbox" ng-change="uncheckFirstCheckbox(secondCheckbox)">Second Checkbox</ion-checkbox>


JS:

    $scope.uncheckFirstCheckbox = function(secondCheckbox) {
        if(secondCheckbox.checked === false) {
            $scope.firstCheckbox = false;
        };
    };


The $scope.firstCheckbox turn false but it remain uncheck in HTML.
May I know where could be the problem?




Aucun commentaire:

Enregistrer un commentaire