javascript - How to pass $q to angular directive link function? -



javascript - How to pass $q to angular directive link function? -

i need utilize $q link function of directive. need wrap possible promise retuned 1 of arguments (see illustration below). don't know however, how pass $q dependency function.

angular.module('directives') .directive('mydirective', function() { homecoming { scope: { onevent: '&' } // ... link: function($scope, $element) { $scope.handleevent() { $q.when($scope.onevent()) { ... } } } } }

just add together dependency on directive , $q usable in link function. because of javascript's closures.

below illustration based on code.

angular.module('directives') .directive('mydirective', ['$q', function($q) { homecoming { scope: { onevent: '&' } // ... link: function($scope, $element) { $scope.handleevent() { $q.when($scope.onevent()) { ... } } } } }])

javascript angularjs angularjs-directive angular-promise

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -