Skip to content

Instantly share code, notes, and snippets.

@jbmyid
Created July 3, 2015 06:58
Show Gist options
  • Select an option

  • Save jbmyid/2ddd736f806470e62694 to your computer and use it in GitHub Desktop.

Select an option

Save jbmyid/2ddd736f806470e62694 to your computer and use it in GitHub Desktop.

Revisions

  1. jbmyid created this gist Jul 3, 2015.
    22 changes: 22 additions & 0 deletions typeheadonclick.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    .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);
    }
    };
    });