From 49fa3f0d48d58a2a9fab3d3abd374fed01a52b77 Mon Sep 17 00:00:00 2001 From: raymond muller Date: Fri, 1 Aug 2014 10:20:54 +0200 Subject: [PATCH 1/3] - updated angular version - added option to limit the number of suggestions shown --- index.html | 4 ++-- script/autocomplete.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index a0569ca..5cc0675 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ Autocomplete Demo - + @@ -16,7 +16,7 @@

AngularJS: Allmighty-Autocomplete Demo

Search for new released movies:

- +
This is a simple autocomplete directive for AngularJS, packaged in a Angular module. You can check out the source code or download it here: diff --git a/script/autocomplete.js b/script/autocomplete.js index aba19c4..695b788 100644 --- a/script/autocomplete.js +++ b/script/autocomplete.js @@ -10,6 +10,7 @@ app.directive('autocomplete', function() { scope: { searchParam: '=ngModel', suggestions: '=data', + limit: '=?', onType: '=onType', onSelect: '=onSelect' }, @@ -17,6 +18,11 @@ app.directive('autocomplete', function() { // the index of the suggestions that's currently selected $scope.selectedIndex = -1; + // // set default limit of suggestions when undefined + if($scope.limit === undefined) { + $scope.limit = Infinity; + } + // set new index $scope.setIndex = function(i){ $scope.selectedIndex = parseInt(i); @@ -49,7 +55,7 @@ app.directive('autocomplete', function() { $scope.selectedIndex = -1; } - // function thats passed to on-type attribute gets executed + // function thats passed to on-type attribute gets executed if($scope.onType) $scope.onType($scope.searchParam); }); @@ -230,7 +236,7 @@ app.directive('autocomplete', function() {
    \ Date: Fri, 1 Aug 2014 10:22:32 +0200 Subject: [PATCH 2/3] typo --- script/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/autocomplete.js b/script/autocomplete.js index 695b788..e273284 100644 --- a/script/autocomplete.js +++ b/script/autocomplete.js @@ -18,7 +18,7 @@ app.directive('autocomplete', function() { // the index of the suggestions that's currently selected $scope.selectedIndex = -1; - // // set default limit of suggestions when undefined + // set default limit of suggestions when undefined if($scope.limit === undefined) { $scope.limit = Infinity; } From 4f7abf9c65b2d1805c0b1f4579b026cefb12a404 Mon Sep 17 00:00:00 2001 From: raymond muller Date: Fri, 1 Aug 2014 10:34:37 +0200 Subject: [PATCH 3/3] update --- script/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/autocomplete.js b/script/autocomplete.js index e273284..710c9e3 100644 --- a/script/autocomplete.js +++ b/script/autocomplete.js @@ -19,7 +19,7 @@ app.directive('autocomplete', function() { $scope.selectedIndex = -1; // set default limit of suggestions when undefined - if($scope.limit === undefined) { + if(!$scope.limit) { $scope.limit = Infinity; }