Skip to content

Instantly share code, notes, and snippets.

Avatar

Väinö Leppänen denarced

View GitHub Profile
@denarced
denarced / gist:d534317e782c83f58e9b
Created Sep 24, 2014
Adapt JQueryUI autocomplete to work with angularJs
View gist:d534317e782c83f58e9b
angular.module('mod').directive('dnAutocomplete', function() {
function link(scope, element, attrs) {
scope.$watch(attrs.dnAutocomplete, function(names) {
element.autocomplete({
source: names,
/**
* The default implementation updates the HTML input's value
* in such a way that the angular doesn't detect it. The
* result is that scope.add.input isn't updated while the
* HTML input itself is. By updating angular's scope object,