In this article I will explain with an example, how to use 
ng-mousedown directive in 
AngularJS.
 
	
		 
	
		 
	
		
			HTML Markup
	
	
		The following HTML Markup consists of:
	
		DIV – For applying 
ng-app and 
ng-controller AngularJS directives.
 
	
	
		 
	
		Button – For capturing user input.
	
		The HTML INPUT Button has been assigned with the following 
AngularJS directive.
 
	
		ng-mousedown – Called when the mouse button is clicked.
	
		SPAN – For displaying message.
	
		
			<div ng-app="MyApp" ng-controller="MyController">
		
			    <input type="button" ng-mousedown="SetCount()" value="Increment" />
		
			    <hr />
		
			    Count: <span style="font-weight:bold">{{Count}}</span>
		
			</div>
	 
	
		 
	
		 
	
		
			Implementing ng-mousedown Directive
	
	
		Inside the HTML Markup, the following 
AngularJS script file is inherited:
 
	
		1. angular.min.js
	
		Then, inside the Controller, the Count variable is set to Zero.
	
		When the mouse button is clicked, the SetCount function is called.
	
		Inside this function, the Count variable is incremented by 1, which will be latter displayed on the page using SPAN element.
	
		
			<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
		
			<script type="text/javascript">
		
			    var app = angular.module('MyApp', [])
		
			    app.controller('MyController', function ($scope) {
		
			        // By default Count is zero.
		
			        $scope.Count = 0;
		
			        $scope.SetCount = function () {
		
			            // Increment the Count by one.
		
			            $scope.Count++;
		
			        }
		
			    });
		
			</script>
	 
	
		 
	
		 
	
		
			Screenshot
	
	
	
		 
	
		 
	
		
			Demo
	
	
	
		 
	
		 
	
		
			Downloads