var app = angular.module('MyApp', [])
app.controller('MyController', function ($scope, $http, $window) {
$scope.showButton = true;
$scope.printToCart = function (printSectionId) {
$scope.showButton = false;
debugger;
var innerContents = document.getElementById(printSectionId).innerHTML;
var popupWinindow = window.open('', '_blank', 'width=600,height=700,scrollbars=no,menubar=no,toolbar=no,location=no,status=no,titlebar=no');
popupWinindow.document.open();
popupWinindow.document.write('<html><head><link rel="stylesheet" type="text/css" href="style.css" /></head><body onload="window.print()">' + innerContents + '</html>');
popupWinindow.document.close();
$window.location.reload();
}
});
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.8/angular.min.js"></script>
<script src="MyController.js" type="text/javascript"></script>
<link href="style.css" rel="stylesheet" />
<div ng-app="MyApp" ng-controller="MyController">
<input type="button" value="Preview" ng-click="printToCart('printSectionId')" id="create_pdf" ng-show="showButton"/>
<form id="printSectionId"></form>