1

I'm working on an AngularJS application and I want to print the view. So I'm I've used the window.print() function, and it does give me the opportunity to print, however nothing shows in the print. How can this be?

My view.controller

angular.module('app')
.controller('viewController', ['$scope', '$state', '$interval', '$window', 'view', 'socketService', function ($scope, $state, $interval, $window, view, socketService) {
    ...
    $scope.print = function () {
        console.log('content is printed');

        window.print();
    };
    ...
}]);


the view.html

...
<table class="table table-striped table-hover">
    <thead>
        <tr>
            <td ng-repeat="value in values">
                <h3>
                    {{ value.shownName | capitalize }}
                </h3>
            </td>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="item in items">
            <td ng-repeat="value in values">
                {{ findMatch(item, value.matchValue) }}
            </td>
        </tr>
    </tbody>
</table>

<div class="viewNavigation">
    <!-- Print -->
    <a href class="btn btn-default" ng-click="print()" ng-show="viewFunctions.print"><i class="glyphicon glyphicon-print"></i> Print</a>

    <div class="clearfix"></div>
</div>
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
Michael Tot Korsgaard
  • 3,892
  • 11
  • 53
  • 89
  • 2
    **[Some help you could get](http://stackoverflow.com/questions/22189544/print-a-div-using-javascript-in-angularjs-single-page-aplication)** – Guruprasad J Rao Nov 03 '15 at 12:52
  • @GuruprasadRao: Thanks ^^ I've looked at similar solutions, however all of them prints the content on a single line, and not as specified in the `view.html`. What I'm looking for is just to call the print function which can be found in most browsers. – Michael Tot Korsgaard Nov 03 '15 at 12:59

0 Answers0