Make debounce delay explicit

This commit is contained in:
Steve Purcell 2013-09-29 17:46:15 +01:00
parent 9d7a19d624
commit 234384d3a7
2 changed files with 4 additions and 3 deletions

View file

@ -171,11 +171,12 @@
require: "ngModel", require: "ngModel",
scope: { scope: {
"ngModel": "=", "ngModel": "=",
"debounceModel": "=" "debounceModel": "=",
"debounceDelay": "@"
}, },
link: function (scope, element, attrs, ngModel) { link: function (scope, element, attrs, ngModel) {
//jshint unused: false //jshint unused: false
var delay = 250; var delay = parseInt(scope.debounceDelay, 10) || 250;
var copyValue; var copyValue;
scope.$watch(function() { scope.$watch(function() {
return ngModel.$modelValue; return ngModel.$modelValue;

View file

@ -4,7 +4,7 @@
<small ng-show="totalDownloads">(<span ng-bind="totalDownloads"></span> downloads to date)</small> <small ng-show="totalDownloads">(<span ng-bind="totalDownloads"></span> downloads to date)</small>
</h2> </h2>
<p> <p>
<input type="text" ng-model="enteredSearchTerms" debounce-model="searchTerms" placeholder="Enter filter terms" autofocus> <input type="text" ng-model="enteredSearchTerms" debounce-model="searchTerms" debounce-delay="250" placeholder="Enter filter terms" autofocus>
<span class="muted">&nbsp;<ng-pluralize when="{1: '1 match', 'other': '{} matches'}" count="(packages | filter:packageMatcher(searchTerms)).length"/></span> <span class="muted">&nbsp;<ng-pluralize when="{1: '1 match', 'other': '{} matches'}" count="(packages | filter:packageMatcher(searchTerms)).length"/></span>
</p> </p>
<table id="package-list" class="table table-bordered table-responsive table-hover"> <table id="package-list" class="table table-bordered table-responsive table-hover">