Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Put this on a button to make it the default
- .directive('autoEnterDirective', ['$document', function($document) {
- return {
- scope: {
- autoEnterDirective: "&"
- },
- link: function(scope, element, attrs) {
- var enterWatcher = function(event) {
- if (event.which === 13) {
- scope.autoEnterDirective();
- scope.$apply();
- ///console.log('ENTER')
- event.preventDefault();
- $document.unbind("keydown keypress", enterWatcher);
- }
- };
- $document.bind("keydown keypress", enterWatcher);
- }
- }
- }])
- <a id="btnFind" class="button small box-shadow-inset" auto-enter-directive="findModal()" ng-click="findModal()">Find</a>
- <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