Created
October 25, 2013 11:43
-
-
Save lotas/7153389 to your computer and use it in GitHub Desktop.
Autocomplete with directive stacking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autocomplete.directive('typeahead', ['$compile', 'AutocompleteService', function ($compile, AutocompleteService) { | |
return { | |
restrict: 'A', | |
priority: 999, | |
link: function ($scope, elm, attrs) { | |
$scope.getItems = function (filter, type, autocompletItems) { | |
var fn = AutocompleteService.getLookupFunction(type, autocompletItems); | |
return fn(filter); | |
} | |
} | |
}; | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Selected: <span ng-bind="loc"></span> | |
<input name="city" typeahead="item for item in getItems($viewValue,'cities')" typeahead-min-length="3" ng-model="loc" /> | |
Another Selected: <span ng-bind="loc2"></span> | |
<input name="city2" typeahead="item for item in getItems($viewValue,'cities')" typeahead-min-length="3" ng-model="loc2" /> | |
Simple complete: <span ng-bind="loc3"></span> | |
<input name="city3" typeahead="item for item in getItems($viewValue, 'simple', 'Berlin,Dresden,rest of the world')" ng-model="loc3" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment