AngularJS Tutorial 5: How to handle button click events using AngularJS

Using this tutorial we are going to learn how to handle button click events in AngularJS.

Please go through below code for your reference.

<!DOCTYPE html>
<html>
<head>
    <script src="angular.min.js"></script>
    <meta charset="utf-8" />
    <script>
        var myApp = angular.module("myModule", []);

        var myController = function ($scope) {
            $scope.AlertMethod = function () {
                alert("This is alert HELLO WORLD program in Angular");
            };
        };

        myApp.controller("myController", myController);
    </script>
</head>
<body ng-app="myModule">

    <div ng-controller="myController">
        <button ng-click="AlertMethod()">Click Me</button>
    </div>

</body>
</html>   

Output:


If you have any queries or suggestions, please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar