Reputation: 940
I am using printThis.js and trying to print html using angularjs. My code is
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.Html = '<div><p>Pakistan</p></div>';
$scope.printMe = function (){
$dvPrint = $($scope.Html);
$dvPrint.printThis();
}
}
Html Code:
<div ng-controller="MyCtrl">
<button id="print_btn" ng-click="printMe()">click it</button><br />
</div>
What issue i am facing is, if i am working on local machine, it works perfect. but if i deploy it on local server then sometime print preview is empty. whereas when debugging deployed code on server printthis.js works.
i tried to increase timeout time in printthis.js but it didn't worked. any thoughts on this issue? My jquery version is 2.1.0
One more thing i would like to add here is, if i edit the html content which i need to print after page is load, then printThis.js will work fine and content will be in print preview. in other case if page rendered and html content is loaded at the first time printThis.js will render empty preview.
Upvotes: 0
Views: 2210
Reputation: 91
can you try in CSS side... This is the code
@media print {
.show{font-size:24px;font-weight:bold;display:block;} }
Upvotes: 1
Reputation: 691
Worked in my localMachine
$scope.Html = '<div><p>Pakistan</p></div>';
$scope.printMe = function () {
$scope.dvPrint = $($scope.Html);
$scope.dvPrint.printThis();
};
Upvotes: 0