我正在使用printThis.js,并尝试使用angularjs打印html。我的代码是
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.Html = '<div><p>Pakistan</p></div>';
$scope.printMe = function (){
$dvPrint = $($scope.Html);
$dvPrint.printThis();
}
}Html代码:
<div ng-controller="MyCtrl">
<button id="print_btn" ng-click="printMe()">click it</button><br />
</div>jsFiddle
我面临的问题是,如果我在本地机器上工作,它可以完美地工作。但是如果我把它部署在本地服务器上,那么有时打印预览是空的。而在服务器上调试部署的代码时,printthis.js可以正常工作。
我试图在printthis.js中增加超时时间,但它不起作用。对这个问题有什么想法?我的jquery版本是2.1.0
我想在这里添加的另一件事是,如果我编辑页面加载后需要打印的html内容,那么printThis.js将工作良好,内容将在打印预览中。在其他情况下,如果在第一次加载页面和html内容时,printThis.js将呈现空预览。
发布于 2016-01-21 20:42:09
你能在CSS端试试吗?这是代码
@media print {.show{font-size:24px;font-weight:bold;display:block;} }
发布于 2016-01-21 20:32:12
在我的localMachine中工作
$scope.Html = '<div><p>Pakistan</p></div>';
$scope.printMe = function () {
$scope.dvPrint = $($scope.Html);
$scope.dvPrint.printThis();
};https://stackoverflow.com/questions/34923659
复制相似问题