Skip to content

Instantly share code, notes, and snippets.

@madzhuga
Created December 16, 2013 09:41
Show Gist options
  • Save madzhuga/7984524 to your computer and use it in GitHub Desktop.
Save madzhuga/7984524 to your computer and use it in GitHub Desktop.
Angular autocomplete with jquery
<div ng-app='MyModule'>
<div ng-controller='DefaultCtrl'>
<input auto-complete ui-items="names" ng-model="selected">
selected = {{selected}}
</div>
</div>
function DefaultCtrl($scope) {
$scope.names = ["john", "bill", "charlie", "robert", "alban", "oscar", "marie", "celine", "brad", "drew", "rebecca", "michel", "francis", "jean", "paul", "pierre", "nicolas", "alfred", "gerard", "louis", "albert", "edouard", "benoit", "guillaume", "nicolas", "joseph"];
}
angular.module('MyModule', []).directive('autoComplete', function($timeout) {
return function(scope, iElement, iAttrs) {
$(iElement).autocomplete({
source: scope[iAttrs.uiItems],
select: function() {
$timeout(function() {
iElement.trigger('input');
####try:
####iElement.trigger('key enter.?'')
}, 0);
}
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment