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..710c9e3 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) { + $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() {
    \