Articles → ANGULAR.JS → ng-click in angular.js

ng-click in angular.js






Purpose





Syntax


<element ng-click="method()"/>



Example


<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
    <script type="text/javascript">
        var app = angular.module('app', []);
        app.controller('myController', function ($scope) {
            $scope.ClickMe = function ()
            {
                alert("Click me");
            }
        });
    </script>

</head>
<body>
    <div ng-app="app" ng-controller="myController">
        <button ng-click="ClickMe()">Click me</button>
    </div>
</body>
</html>



Output



Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Friday, February 03, 2017

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250