Skip to content

Instantly share code, notes, and snippets.

@jbmyid
Created July 3, 2015 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbmyid/2ddd736f806470e62694 to your computer and use it in GitHub Desktop.
Save jbmyid/2ddd736f806470e62694 to your computer and use it in GitHub Desktop.
Open ng-typeahea on click
.directive('typeaheadClickOpen', function($parse, $timeout) {
var dir;
return dir = {
restrict: 'A',
require: 'ngModel',
link: function($scope, elem, attrs) {
var triggerFunc;
triggerFunc = function(evt) {
var ctrl, prev;
ctrl = elem.controller('ngModel');
prev = ctrl.$modelValue || '';
ctrl.$setViewValue(prev ? '' : ' ');
if (prev) {
return $timeout(function() {
return ctrl.$setViewValue("" + prev);
});
}
};
return elem.bind('click', triggerFunc);
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment