Print Functionality in Angular Js

971 views
Skip to first unread message

Rakesh Soundararajan

unread,
Nov 3, 2014, 5:05:22 AM11/3/14
to ang...@googlegroups.com
Hi All,

Is angular js providing print functionality(For eg - something like ng-print directive), if so please suggest me or anybody having any solutions please let me know it will be a pleasure for me.

Currently I am using java script print function.

<div id="printableArea">
      <h1>Print me</h1>
</div>

<input type="button" onclick="printDiv('printableArea')" value="print a div!" />
Now let's create a really simple javascript:

function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}


Thanks and Regards,
T.S.Rakesh

Naveen Kohli

unread,
Nov 3, 2014, 8:06:00 AM11/3/14
to ang...@googlegroups.com
Use CSS @media queries to manage your printable areas.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages