($parse, $rootScope, $exceptionHandler, directiveName, eventName, forceAsync)
| 29005 | ); |
| 29006 | |
| 29007 | function createEventDirective($parse, $rootScope, $exceptionHandler, directiveName, eventName, forceAsync) { |
| 29008 | return { |
| 29009 | restrict: 'A', |
| 29010 | compile: function($element, attr) { |
| 29011 | // NOTE: |
| 29012 | // We expose the powerful `$event` object on the scope that provides access to the Window, |
| 29013 | // etc. This is OK, because expressions are not sandboxed any more (and the expression |
| 29014 | // sandbox was never meant to be a security feature anyway). |
| 29015 | var fn = $parse(attr[directiveName]); |
| 29016 | return function ngEventHandler(scope, element) { |
| 29017 | element.on(eventName, function(event) { |
| 29018 | var callback = function() { |
| 29019 | fn(scope, {$event: event}); |
| 29020 | }; |
| 29021 | |
| 29022 | if (!$rootScope.$$phase) { |
| 29023 | scope.$apply(callback); |
| 29024 | } else if (forceAsync) { |
| 29025 | scope.$evalAsync(callback); |
| 29026 | } else { |
| 29027 | try { |
| 29028 | callback(); |
| 29029 | } catch (error) { |
| 29030 | $exceptionHandler(error); |
| 29031 | } |
| 29032 | } |
| 29033 | }); |
| 29034 | }; |
| 29035 | } |
| 29036 | }; |
| 29037 | } |
| 29038 | |
| 29039 | /** |
| 29040 | * @ngdoc directive |
no test coverage detected