【问题标题】:Generate HTML Canvas from AngularJS Template从 AngularJS 模板生成 HTML 画布
【发布时间】:2015-09-19 11:38:42
【问题描述】:

我正在尝试使用 html2canvas JS 在画布上呈现 html 元素。但是我使用 AngularJS 在 html 页面上进行数据绑定,并且动态数据不会呈现在从这些 html 元素生成的画布上。例如,我有一个这样的 html 元素:

<table class="table table-striped table-bordered table-hover">
    <tr>
        <th>Name</th>
        <th>URI</th>
        <th>Is Default</th>
        <th>Action</th>
    </tr>
    <tr ng-repeat="printer in printers">
        <td>{{printer.name}}</td>
        <td>{{printer.url}}</td>
        <td>{{printer.default}}</td>
        <td><button ng-click="printTestPage(printer.url)">Print Test Page</button></td>
    </tr>
</table>

但是我们可以看到动态数据并没有呈现在画布上:

关于如何正确使用或不使用 html2canvas js 的任何建议???

【问题讨论】:

    标签: javascript html angularjs canvas


    【解决方案1】:

    什么时候调用 html2canvas? 您应该在 dom 渲染后调用该函数

    【讨论】:

    • 是的,我在渲染 dom 后调用 html2canvas,但它不起作用。
    • 云你发布整个代码? ,我遇到了类似的问题,您可以通过此链接查看我的代码。 github.com/zackexplosion/angular-rails-blog/blob/master/app/…
    • 剩下的代码就是一个调用htmlToCanvas的脚本...
    • 您的 html 中没有带有“打印机”的 id
    猜你喜欢
    • 1970-01-01
    • 2018-04-17
    • 1970-01-01
    • 1970-01-01
    • 2013-04-08
    • 2015-09-07
    • 1970-01-01
    • 2018-03-07
    • 1970-01-01
    相关资源
    最近更新 更多