How to set checkbox checked on button click in AngularJS? Last Updated : 01 Aug, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how to set checkboxes checked with the click of a button in AngularJS. Approach: The approach is to use the ng-checked directive to check the checkbox in the DOM. In the first example, a single checkbox is checked by the button and In the second example, multiple checkboxes are checked by the button. The ng-model directive is used to bind the checkboxes. Example 1: This example describes the implementation of the ng-checked directive to check the checkbox in AngularJS. HTML <!DOCTYPE HTML> <html> <head> <script src= "//ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"> </script> <script> var myApp = angular.module("app", []); myApp.controller("controller", function ($scope) { $scope.checkIt = function () { if (!$scope.check) { $scope.check = true; } else { $scope.check = false; } } }); </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h3> How to set checkbox checked on button click in AngularJS </h3> <div ng-app="app"> <div ng-controller="controller"> Checkbox: <input type="checkbox" ng-checked="check"> <br> <br> <button ng-click="checkIt()" ng-model='check'> Click to Check </button> <br> <br> </div> </div> </body> </html> Output: Example 2: This example describes the implementation of the ng-checked directive by specifying the multiple checkboxes to check by clicking the button in AngularJS. HTML <!DOCTYPE HTML> <html> <head> <script src= "//ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"> </script> <script> var myApp = angular.module("app", []); myApp.controller("controller", function ($scope) { $scope.checkIt = function () { if (!$scope.check) { $scope.check = true; } else { $scope.check = false; } } }); </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h3> How to set checkbox checked on button click in AngularJS </h3> <div ng-app="app"> <div ng-controller="controller"> Checkbox1: <input type="checkbox" ng-checked="check"> <br> Checkbox2: <input type="checkbox" ng-checked="check"> <br> Checkbox3: <input type="checkbox" ng-checked="check"> <br><br> <button ng-click="checkIt()" ng-model='check'> Click to Check </button> <br><br> </div> </div> </body> </html> Output: Comment More infoAdvertise with us P PranchalKatiyar Follow Improve Article Tags : AngularJS HTML-Misc AngularJS-Misc Similar Reads Angular Interview Questions and Answers Angular is a popular framework for building dynamic web applications. Developed and maintained by Google, Angular allows developers to create fast, efficient, and scalable single-page applications (SPAs) that provide a seamless user experience. Google, Accenture, Microsoft, PayPal, Upwork, Netflix, 15+ min read Frontend Developer Interview Questions and Answers Frontend development is an important part of web applications, and it is used to build dynamic and user-friendly web applications with an interactive user interface (UI). Many companies are hiring skilled Frontend developers with expertise in HTML, CSS, JavaScript, and modern frameworks and librarie 15+ min read Angular Tutorial Angular is a powerful, open-source web application framework for building dynamic and scalable single-page applications (SPAs). Developed by Google, Angular provides a comprehensive solution for front-end development with tools for routing, form handling, HTTP services, and more.Designed for buildin 4 min read Design a Webpage for online food delivery system using HTML and CSS Creating your own online food delivery website is a great way to present a user-friendly platform for customers to browse and order food online. In this project, weâll design a simple yet effective food delivery website using HTML and CSS.What Weâre Going to Create...Weâll develop a straightforward 7 min read AngularJS Tutorial AngularJS is a free and open-source JavaScript framework that helps developers build modern web applications. It extends HTML with new attributes and it is perfect for single-page applications (SPAs). AngularJS, developed by Google, has been important in web development since its inception in 2009. 5 min read Introduction to AngularJS AngularJS is a popular open-source framework that simplifies web development by creating interactive single-page applications (SPAs). Unlike traditional websites that load new pages for each click, SPAs offer a smoother user experience by updating content on the same page. AngularJS makes this possi 4 min read How to Add Video in HTML? To add a video in HTML, you use the <video> tag, which allows you to embed videos directly into your webpage for users to view without needing external players.The <video> tag supports multiple formats like MP4, WebM, and Ogg.You can include attributes such as controls, autoplay, and loo 4 min read Angular CLI | Angular Project Setup Angular is an open-source front-end web application framework that is used for building single-page and complex web applications. By default, angular uses TypeScript for creating logic but as the browser doesn't know typescript it converts typescript into javascript in order to make typescript under 3 min read Difference between <div> and <span> Tag in HTML In HTML, the <div> and <span> tags are used for structuring and styling content. <div> creates block-level containers for grouping elements, while <span> creates inline containers for styling specific portions of text or elements within a block-level container. Syntax: <di 3 min read How to Insert Form Data into Database using PHP ? Inserting form data into a MySQL database using PHP allows web applications to store user inputs like registrations or feedback. By collecting and validating the data from HTML forms, PHP securely inserts it into the database, ensuring data integrity and protection against security risks.Here, we wi 5 min read Like