2017-08-13 80 views
0

我想从我使用angularjs生成的HTML生成PDF,但是当我使用角URL请求(通过requestify)而不是页面内容时,我得到index.html页......没有人知道如何让HTML内容的ng-view从URL加载HTML内容AngularJS

$routeProvider .when('/mediakit/:account', { templateUrl: 'app/mediakit/mediakit.html', controller: 'MediaKitCtrl' });

我想从http://localhost:9000/mediakit/accountid使用mediakit.html为模板不是index.html的内容(其中的内容是内容产生通过ng-view加载)

我使用生成PDF

let pdf = require('html-pdf'); 
     let requestify = require('requestify'); 
     let outputPath = './server/public/'; 
     //req.body.mediaKitURL --> is the URL that I load the content when I open in the browser 
     requestify.get(req.body.mediaKitURL).then(function (response) { 
     // Get the raw HTML response body 
     let html = response.body; --> //the content here is the content from index.html, 
     //I would like to get the content from the my angular route that uses mediakit.html (same when I open the URL in the browser) 
     let config = {format: 'letter'}; 

    // Create the PDF 
     pdf.create(html, config).toFile(outputPath + '/media_kit_'+req.params.account+'.pdf', function (err, result) { 
      if (err) return console.log(err); 
      console.log(result); // { filename: '/pathtooutput/generated.pdf' } 
      res.status(200).json(); 
     }); 
     }); 

我希望这是明确的代码...

回答