Skip to content

print-btn directive causing click event on element is fired after print window closed  #31

@yuvarajramasamy

Description

@yuvarajramasamy
test() method is fired after print window is closed

Plunker link :https://plnkr.co/edit/l9dnC2KnChznUf8mk1As?p=preview

Fix:
invoke $window.print inside $timeout()

AngularPrint.directive('printBtn',['$window','$timeout', function($window,$timeout){
       return {
           restrict: 'A',
           link: function(scope, element){
               element.on('click', function(event){
                 
                   $timeout(function () {
                         $window.print();
   }, 0); 
               });
           }
       };
   }]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions