mardi 17 octobre 2017

AngularJS - How to set the value of the checkbox as true by checking another checkbox?

I have two checkboxes. If you click checkbox B, checkbox A must be checked too. But in my code, when I click checkbox B, the checkbox A is also checked. But the ng-model of checkbox A is not changing it's value from false to true. Can someone help me with this? Thank you in advance! Here's my code below: (Try running the code snippet)

<div ng-app="myApp" ng-controller="myCtrl">
    Box a
    <input type="checkbox" ng-checked="box2" ng-model="box1"><br />
    Box b
    <input type="checkbox" ng-model="box2"> 
    </div>

    <script src="http://ift.tt/2pBcIa3"></script>
    <script>
    var app = angular.module('myApp', []);
            app.controller('myCtrl', function ($scope) {
            $scope.box1 = false;
            $scope.box2 = false;
            });
    </script>



Aucun commentaire:

Enregistrer un commentaire