Advertisement
andrewb

checkbox.html

Jan 4th, 2016
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.66 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
  5. </head>
  6. <body>
  7. <div ng-app="testApp" ng-controller="checkCtrl">
  8. <p>{{checkedOrNot}}</p>
  9. <label for="theCheck">Click here</label>
  10. <input type="checkbox" id="theCheck" name="theCheck" ng-click="updateSelection($event)">
  11. </div>
  12. <script>
  13. var app = angular.module('testApp', []);
  14. app.controller('checkCtrl', function($scope) {
  15.     $scope.checkedOrNot = "No";
  16.  
  17.     $scope.updateSelection = function($event) {
  18.         var cb = $event.target;
  19.         var con = (cb.checked ? 'Yes' : 'No');
  20.         $scope.checkedOrNot = con;
  21.     };
  22. });
  23. </script>
  24. </body>
  25. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement