Angular在打印表单时只显示空白页
Angular formly only shows blank page when printing form
我试图创建一个按钮,用户可以打印页面为他们的记录,但它一直显示空白使用形式,我假设因为表单是动态生成的。我在打印按钮中使用打印指令:
(function (angular) {
'use strict';
function printDirective() {
var printSection = document.getElementById('printSection');
// if there is no printing section, create one
if (!printSection) {
printSection = document.createElement('div');
printSection.id = 'printSection';
document.body.appendChild(printSection);
}
function link(scope, element, attrs) {
element.on('click', function () {
var elemToPrint = document.getElementById(attrs.printElementId);
if (elemToPrint) {
printElement(elemToPrint);
}
});
window.onafterprint = function () {
// clean the print section before adding new content
printSection.innerHTML = '';
}
}
function printElement(elem) {
// clones the element you want to print
var domClone = elem.cloneNode(true);
printSection.appendChild(domClone);
window.print();
}
return {
link: link,
restrict: 'A'
};
}
angular.module('formlyApp').directive('ngPrint', [printDirective]);
}(window.angular));
这是打印按钮:
<button class="btn btnSubmit" type="submit" ng-print print-element-id="printSection" ng-hide="vm.iForm.$invalid">Print and Save</button>
当我按下按钮时,打印窗口弹出,但除了显示页面名称和日期外,页面是空白的。怎样才能打印出格式字段?
看看angularPrint。
相关文章:
- 谷歌图表显示空白白色页面
- javascript 显示空白灰色层
- 从java调用javascript后显示空白页面
- 当从jquery的点击事件中的每个循环创建的数组到它之外时,它显示空白数组
- Facebook Javascript SDK提要对话框显示空白窗口
- 漫游滑轨只显示空白屏幕
- LinkedIn关注显示空白页的公司按钮
- 我的网站在移动版式镶版式右侧显示空白区域,但桌面版式版式显示空白区域
- 反应 Redux 路由器显示空白页
- 防止 Android 网络视图在导航时显示空白屏幕
- PhoneGap安卓系统:谷歌地图api v3显示空白屏幕
- 谷歌地图API显示空白地图
- 直接加载时显示空白页(PHP)
- angularJS显示空白页面没有错误-控制器问题
- 谷歌地图API显示空白地图时,从HTML5地理位置提供LatLng线
- 显示空白图表,然后使用按钮更新(谷歌图表)
- 我正在写以下代码,但显示空白页
- 在应用JavaScript之前显示空白网站
- AngularJS格式化程序-如何显示空白而不是零
- 警报在javascript中显示空白值