ItSolutionStuff.com

AngularJS Check Checkbox is Checked or Not Example

By Hardik Savani October 20, 2023
Angular

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

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy