Skip to content

Instantly share code, notes, and snippets.

View yangli-io's full-sized avatar
😆
Having a great time

Yang Li yangli-io

😆
Having a great time
View GitHub Profile
angular.module('app', []).directive('ngDebounce', function($timeout) {
return {
restrict: 'A',
require: 'ngModel',
priority: 99,
link: function(scope, elm, attr, ngModelCtrl) {
if (attr.type === 'radio' || attr.type === 'checkbox') return;
elm.unbind('input');
@yangli-io
yangli-io / ng-debounce.js
Last active August 29, 2015 14:13 — forked from tommaitland/ng-debounce.js
Updated debounce to not debounce after a certain amount of characters.
angular.module('app', []).directive('ngDebounce', function($timeout) {
return {
restrict: 'A',
require: 'ngModel',
priority: 99,
link: function(scope, elm, attr, ngModelCtrl) {
var debounce;
var maxLength; //maximum length for debounce to take effect
if (attr.type === 'radio' || attr.type === 'checkbox') return;