Prev Demo
AngularJS
>
Checkbox
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <h2>Check box</h2> <script> var app = angular.module("app", []); app.controller("CheckBoxController", function ($scope) { $scope.chkVal1 = false; $scope.chkVal2 = 'Female'; $scope.GetValue = function () { alert($scope.chkVal1 + ' ' + $scope.chkVal2); } }); </script> <div ng-app="app" ng-controller="CheckBoxController"> Simple: <input id="chk1" type="checkbox" ng-model="chkVal1" /> {{ chkVal1 }} <p> Checkbox with custom value: Are you male? <input id="chk2" type="checkbox" ng-model="chkVal2" ng-false-value="'Female'" ng-true-value="'Male'" /> {{ chkVal2 }} </p> <button ng-click="GetValue()">Get Value</button> </div> </body> </html>
Note: We DO NOT save your trial code in our database.
Output