AngularJS Check Checkbox is Checked or Not Example
Here, i want to show you how to check checkbox is checked or not in angular js app. i will give you simple example to check checkbox is checked or not using ng-app, ng-controller, ng-model and ng-click in angularjs.
it is a simple example that will help to detect checkbox is checked or not. so if you want to quick check then check also demo and also copy bellow html code for check if checkbox is selected.
index.html
<!doctype html>
<html>
<head>
<title>AngularJS Check Checkbox is checked or not - ItSolutionStuff.com</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body ng-app='myapp'>
<div ng-controller="appCtrl">
<input type='checkbox' value='1' ng-model='checkboxEl'><br>
<input type='button' ng-click='checkVal()' value='Click'>
<br>
Result : <span >{{ result }}</span>
</div>
</body>
<script type="text/javascript">
var app = angular.module('myapp', []);
app.controller('appCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.checkVal = function(){
if ($scope.checkboxEl) {
$scope.result = "Checkbox is checked";
} else {
$scope.result = "Checkbox is not checked";
}
}
}]);
</script>
</html>
I hope it can help you....
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- AngularJS Convert Comma Separated String to Array Example
- How to Call AngularJS Controller Function in JQuery?
- AngularJS Image Upload with Preview Example
- How to Hide Div After Some Time in AngularJS?
- How to Call Function on Page Load in AngularJS?
- AngularJS Tooltip using UI Bootstrap tpls HTML Example
- AngularJS Simple Datepicker Directive Example Tutorial
- AngularJS Sorting(using Orderby Filter) Table Data Example
- How to Change Date Format using Date Filter in AngularJS?
- AngularJS - How to Limit String Length using Filter?
- AngularJS - How to Capitalize the First Letter of Word Example
- How to Remove HTML Tags from String in AngularJS?
- PHP AngularJS CRUD with Search and Pagination Tutorial