AngularJS ng-dblclick examples

Example1

AngularJS ng-gblclick example to increment a variable on every double click.

<div ng-app="myApp" ng-controller='MyCtrl'>
  <button ng-dblclick="count = count + 1" ng-init="count=0">Double click to increment</button>
  <div>count: {{count}}</div>
</div>

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>
<script>
  var module = angular.module('myApp', []);
  module.controller('MyCtrl', function($scope) {});
</script>
refresh

Example2

AngularJS ng-dblclick example to increment a variable on every double click. This time use function “inc” to increment the variable.

<div ng-app="myApp" ng-controller='MyCtrl'>
  <button ng-dblclick="inc()" ng-init="count=0">Double click to increment</button>
  <div>count: {{count}}</div>
</div>

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>
<script>
var module = angular.module('myApp', []);
module.controller('MyCtrl', function($scope) {
  $scope.inc = function() {
    $scope.count += 1;
  };
});
</script>
refresh

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments