cmurnick / Capstone

0 stars 0 forks source link

Grocery Page, add print button of grocery list #20

Open cmurnick opened 6 years ago

cmurnick commented 6 years ago

WHEN a user is on the grocery list page THEN they can press a print button and print off their list

cmurnick commented 6 years ago
<div>
  <div>
    Do not print
  </div>
  <div id="printable">
    Print this div
  </div>
  <button ng-click="printDiv('printableArea');">Print Div</button>
</div>

$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 + '</body></html>');
  popupWin.document.close();
}