($parse, $rootScope, $exceptionHandler, directiveName, eventName, forceAsync)
| 28940 | ); |
| 28941 | |
| 28942 | function createEventDirective($parse, $rootScope, $exceptionHandler, directiveName, eventName, forceAsync) { |
| 28943 | return { |
| 28944 | restrict: 'A', |
| 28945 | compile: function($element, attr) { |
| 28946 | // NOTE: |
| 28947 | // We expose the powerful `$event` object on the scope that provides access to the Window, |
| 28948 | // etc. This is OK, because expressions are not sandboxed any more (and the expression |
| 28949 | // sandbox was never meant to be a security feature anyway). |
| 28950 | var fn = $parse(attr[directiveName]); |
| 28951 | return function ngEventHandler(scope, element) { |
| 28952 | element.on(eventName, function(event) { |
| 28953 | var callback = function() { |
| 28954 | fn(scope, {$event: event}); |
| 28955 | }; |
| 28956 | |
| 28957 | if (!$rootScope.$$phase) { |
| 28958 | scope.$apply(callback); |
| 28959 | } else if (forceAsync) { |
| 28960 | scope.$evalAsync(callback); |
| 28961 | } else { |
| 28962 | try { |
| 28963 | callback(); |
| 28964 | } catch (error) { |
| 28965 | $exceptionHandler(error); |
| 28966 | } |
| 28967 | } |
| 28968 | }); |
| 28969 | }; |
| 28970 | } |
| 28971 | }; |
| 28972 | } |
| 28973 | |
| 28974 | /** |
| 28975 | * @ngdoc directive |
no test coverage detected