Skip to content

Instantly share code, notes, and snippets.

View estevanio's full-sized avatar

Estevan Saucedo estevanio

View GitHub Profile
var app= angular.module('app', ['ngCordova']);
app.factory('PrintSvc', ['$rootScope', '$compile', '$http', '$timeout', '$q', '$cordovaPrinter', function($rootScope, $compile, $http, $timeout, $q, $cordovaPrinter) {
var printUrl = function(templateUrl, data) {
$http.get(templateUrl).success(function(template) {
var printScope = $rootScope.$new();
angular.extend(printScope, data);
var element = $compile(angular.element('<div>' + template + '</div>'))(printScope);
var waitForRenderAndPrint = function() {
var app=angular.module('app', []);
app.factory('PrintSvc', ['$rootScope', '$compile', '$document', '$http', '$timeout', '$q', function($rootScope, $compile, $document, $http, $timeout, $q) {
var printHtml = function(html) {
var deferred = $q.defer();
var iframe = document.createElement('iframe');
iframe.setAttribute("style", "display: none;");
$document.find('body').eq(0).append(iframe);
var hiddenframe = $document.find('iframe')[0];
hiddenframe.contentWindow.printAndRemove = function() {