首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从URL AngularJS加载HTML内容

从URL AngularJS加载HTML内容
EN

Stack Overflow用户
提问于 2017-08-14 05:24:34
回答 1查看 568关注 0票数 0

我试图从我使用angularjs生成的超文本标记语言生成PDF,但是当我使用angular URL请求(通过requestify)而不是页面内容时,我得到的是index.html page...does的内容任何人都知道如何在ng-view上生成超文本标记语言内容

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

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

我用来生成PDF的代码

代码语言:javascript
复制
    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();
        });
      });

我希望这是清楚的..。

EN

回答 1

Stack Overflow用户

发布于 2017-08-14 18:07:38

我认为您正在搜索pdf查看器来显示生成的pdf文件内容。

为此,请参考angularjs指令,

https://github.com/legalthings/angular-pdfjs-viewer

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45665050

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档