debouncing for click event in angular js

Viewed 562

To improve web performance of my web application, I want to implement debouncing of click event in angular js, is there library/directive which support debouncing of click event?

1 Answers

try ng-debounce-click event in angular js

ng-debounce-click is a directive used to make sure that expensive/time-consuming function does not fire so often that may cause low web performance. we can limit the rate of invokation of function.

Download

How to use it:

HTML

<div ng-app='myApp' ng-controller='myCtrl'> 
       <input type="button" ng-debounce-click="myOnClickExpensiveFunction()" ng-debounce-options="{time:1000}" value="Click Me">
  </div>

JS

// include the `ngDebounceClick` module
    var app = angular.module('myApp', ['ngDebounceClick']);
    app.controller('myCtrl', function($scope) {
        $scope.myOnClickExpensiveFunction = function() {
          //TODO : Some Expensive implementation.
        };

    });
Related