angular.module('directives') .directive('myDirective',function() { return { scope: { onEvent: '&' } // ... link: function($scope,$element) { $scope.handleEvent() { $q.when($scope.onEvent()) { ... } } } } }
以下是基于您的代码的示例.
angular.module('directives') .directive('myDirective',['$q',function($q) { return { scope: { onEvent: '&' } // ... link: function($scope,$element) { $scope.handleEvent() { $q.when($scope.onEvent()) { ... } } } } }])