Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. //Put this on a button to make it the default
  2. .directive('autoEnterDirective', ['$document', function($document) {
  3. return {
  4. scope: {
  5. autoEnterDirective: "&"
  6. },
  7. link: function(scope, element, attrs) {
  8. var enterWatcher = function(event) {
  9. if (event.which === 13) {
  10. scope.autoEnterDirective();
  11. scope.$apply();
  12. ///console.log('ENTER')
  13. event.preventDefault();
  14. $document.unbind("keydown keypress", enterWatcher);
  15. }
  16. };
  17. $document.bind("keydown keypress", enterWatcher);
  18. }
  19. }
  20. }])
  21.  
  22. <a id="btnFind" class="button small box-shadow-inset" auto-enter-directive="findModal()" ng-click="findModal()">Find</a>
  23.  
  24. <a id="btnFind" class="button small box-shadow-inset" auto-enter-directive="findModal()" ng-click="findModal()">Find</a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement