In this article I will explain with an example, how to print DIV contents with CSS using AngularJS.
This article will illustrate how to print DIV contents with styles in external CSS file without opening new window in AngularJS.
External CSS file
The following external CSS file contains the styling for the HTML DIV.
    font-size: 10pt;
    font-weight: bold;
    font-family: Arial;
    border: 1px dotted black;
    padding: 5px;
    width: 300px;
    color: #18B5F0;
    float: left;
    width: 50px;
    height: 50px;
    margin-left: 60px;
    clear: both;
Printing DIV contents with CSS using AngularJS
The below HTML Markup consists of an HTML DIV to which ng-app and ng-controller AngularJS directives have been assigned.
The HTML DIV consists of an HTML DIV whose contents will be printed and a Button.
Note: If you want to learn more about these directives, please refer my article Introduction to AngularJS.
The Button has been assigned ng-click directive. When the Image is clicked, the PrintDIV function of the Controller gets called.
Note: If you want to learn more about ng-click directive, please refer my article ng-click directive example.
Inside the PrintDIV function, first the contents of the HTML DIV to be printed are extracted.
Then a dynamic IFRAME is created and the extracted contents of the HTML DIV are written to the IFRAME along with the link to the external CSS file and finally the IFRAME document is printed using the JavaScript Window Print command and the IFRAME is removed from the page.
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        var app = angular.module('MyApp', [])
        app.controller('MyController', function ($scope, $window) {
            $scope.PrintDIV = function () {
                var contents = document.getElementById("dvContents").innerHTML;
                var body = document.getElementsByTagName("BODY")[0];
                //Create a dynamic IFRAME.
                var frame1 = document.createElement("IFRAME");
       = "frame1";
                frame1.setAttribute("style", "position:absolute;top:-1000000px");
                //Create a Frame Document.
                var frameDoc = frame1.contentWindow ? frame1.contentWindow : frame1.contentDocument.document ? frame1.contentDocument.document : frame1.contentDocument;
                //Create a new HTML document.
                frameDoc.document.write('<html><head><title>DIV Contents</title>');
                //Append the external CSS file.
                frameDoc.document.write('<link href="style.css" rel="stylesheet" type="text/css" />');
                //Append the DIV contents.
                $window.setTimeout(function () {
                }, 500);
    <div ng-app="MyApp" ng-controller="MyController">
        <link href="style.css" rel="stylesheet" type="text/css" />
        <div id="dvContents">
            <div class="left">
                <img alt="" src="images/ASPSnippets.png" />
            <div class="right">
                <span class="label"> Sample page</span>
            <div class="clear">
            <hr />
            <div class="contents">
                <span class="label">Hello,
                    <br />
                    This is <span class="name">Mudassar Khan</span>.<br />
                    Hoping that you are enjoying my articles! </span>
        <br />
        <input type="button" value="Print" ng-click="PrintDIV()" />
HTML DIV Contents
Print DIV contents with CSS using AngularJS
Printed HTML DIV with CSS
Print DIV contents with CSS using AngularJS
Browser Compatibility

The above code has been tested in the following browsers.

Internet Explorer  FireFox  Chrome  Safari  Opera 

* All browser logos displayed above are property of their respective owners.