<div class="row">
<div class="col-md-3">
link 1
link 2
link 3
.
.
.
</div>
</div>
<div class="col-md-9">
<div ng-view></div>
</div>
當鏈接被點擊子頁面將在NG-查看裝入>
<table class='table table-bordered'>
<tr>
<td>
this is my screen view
when user clicks a link in parent page
specific contentd loaded here
</td>
</tr>
</table>
<button type="button" class="btn btn-success btn-md" ng-click="myprint()" >
<span class="glyphicon glyphicon-print"></span> Print
</button>
<div id ="printsection">
<table style="width:80mm;">
<tr style="text-align: center;">
<td>this is my print view contents
send these contents
to print to printer
</td>
</tr>
</table>
</div>
以上子頁有2個部分。屏幕視圖和printsection。
我想要當用戶點擊打印按鈕時,printsection內容發送到打印機。
我已經爲介質打印定義了這些CSS規則。
print.css
body {
background-color: white;
color: black;
font-family: Times,"Times New Roman",Garamond, serif;
}
body * {
visibility: hidden;
}
#printsection * {
visibility: visible;
}
#printsection {
position: absolute;
left: 0;
top: 0;
}
問題是打印按鈕,它隱藏所有內容,甚至是印刷部分的點擊。
我在做什麼錯了?
請注意我使用的POS打印機80毫米寬度,dats我在printsection寬度= 80毫米。
怎麼樣myprint()函數? – felipsmartins
這應該涵蓋你:http://stackoverflow.com/questions/22189544/print-a-div-using-javascript-in-angularjs-single-page-aplication –
我的打印程序是: \t $ scope。myprint = function(){ \t \t window.print(); \t} –