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>
If you have any queries or suggestions, please feel free to ask in comments section.
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:
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.