Skip to content Skip to sidebar Skip to footer

Print Function Is Calling Before Partial View

What I am trying to do is to open partial view in new window and call print function, but problem is that partial view renders after print function so I always get a blank page. I

Solution 1:

make the data "package" a promise inside your controller:

angular.module("printModule").controller('printController', ['$scope', '$window', '$q', function ($scope, $window, $q) { 


$scope.ticketPin = localStorage.getItem("pin"); 
$scope.payoutTime = localStorage.getItem("payoutTime"); 
$scope.payoutAmount = localStorage.getItem("payoutAmount"); 

var defer = $q.defer(); 
defer.resolve($scope.ticketPin); 
defer.resolve($scope.payoutTime); 
defer.resolve($scope.payoutAmount); 

defer.promise.then(function () { 
    $window.print(); 
}) 
}]);

have a nice day ;)

Post a Comment for "Print Function Is Calling Before Partial View"