Phantom wont initialize / load angularjs controller methods
I need help generating a PDF file from an html page powered by an angularjs controller. pdf will be generated using the phantom module. im able to display and bind data correctly as soon as i go to a specific url, but when i call phantom to render the page it doesnt load / initialize / call controller methods, i tried different methods like doing ng-init from div or function call from controller once loading is done or even with
$scope.$on('$viewContentLoaded', function(){
//code here...
})
phantom code:
function DoThePDF(){
phantom.create(function(ph){
ph.createPage(function(page) {
page.set("paperSize", { format: "A4", orientation: 'portrait', margin: '1cm' });
page.open(address, function(status) {
if(status !== 'success'){
console.log('unable to open webpage');
}
else{
setTimeout(function() {
page.render("reports.pdf");
console.log("page rendered");
ph.exit();
}, 5000);
}
})
})
});
}
when calling page.open (address, function (status) {...} I can see that the page has been opened, but angular events / methods do not get initialized / called, so when the page is rendered is an empty html template, data I added delays but still doesn't help.
+3
source to share