0
我有一個翡翠的HTML文件上的打印一個特定的div元素玉頁面
include ../../../public/UI-Master-Layout/Jade/userMenu.jade
include ../../../public/UI-Master-Layout/Jade/footer.jade
include ../../mixinHelp.jade
div.container.cstm-panel-heading(ng-controller="studentInformationCtrl")
.container
.row
.col-lg-12
div#printableArea
table.cstm-panel-heading.darkgray(align='center')
colgroup
col(width="50%")
col(width="50%")
tbody
tr
td(colspan='2' align='center') Student Information
tr
td First Name
td {{student.firstName}}
tr
td Last Name
td {{student.lastName}}
button.btn.btn-info.pull-right(type='button',ng-click="printDiv('printableArea')") Print
我有我的控制器文件
angular.module('XXXX')
.controller('studentInformationCtrl', ['$scope', '$http','$window', function ($scope, $http, $window) {
$scope.printDiv = function(divName) {
var printContents = document.getElementById(divName).innerHTML;
var popupWin = window.open('', '_blank', 'width=300,height=300');
popupWin.document.open()
popupWin.document.write('<html><head><link rel="stylesheet" type="text/css" href="style.css" /></head><body onload="window.print()">' + printContents + '</html>');
popupWin.document.close();
}
}]);
如果我只是做了$ window.print()我得到打印的值。但我試圖打印選定的div printableArea。我缺少了什麼