I've got a printing service, it has a function that gets passed the template url and data for the template.
I need to somehow populate that template with the data provided and then open it in a new window. Here's pseudo code for my idea:
PrintWindow.printModal = function(data, template) {
get(template).success(function(data) {
populatedTemplate = populate(template)
var mywindow = window.open('', '_blank');
mywindow.document.write('<html><head>');
mywindow.document.write('</head><body>');
mywindow.document.write(populatedTemplate);
mywindow.document.write('</body></html>');
});
return true;
};
How could I achieve this?