【问题标题】:how to change the popup window config in typescript?如何更改打字稿中的弹出窗口配置?
【发布时间】:2018-04-26 11:52:07
【问题描述】:

我正在使用 angular 并且我有一个弹出窗口,当我第一次打开它时,它有边距:默认值,但我想要边距:无。我该怎么做?

这是代码:

popupWin = window.open('', '_blank', 'top=150,left=0,height=auto,width=auto');
popupWin.document.open();
popupWin.document.write(
  '<html><head></head><body onload="window.print();window.close()"><p>' + headContents + '</p> <div>' + innerContents + '</div> <table><tr>' + '<td>' + this.sign + '</td></tr><tr><td>' + this.sender + '</td></tr></table> </body></html>');
popupWin.document.close();

【问题讨论】:

  • 您的代码在哪里?你试过什么?发布至少代码以了解您的问题
  • @pardeep-jain 我编辑了我的帖子!这是一个简单的弹出窗口

标签: angular margin default popupwindow


【解决方案1】:

您可以使用ng2-opd-popup npm 包来显示弹出窗口
在您的项目上安装:

npm i ng2-opd-popup

然后导入到模块中

import {PopupModule} from 'ng2-opd-popup';

@NgModule({
  imports: [
    ...
    PopupModule.forRoot()
  ],

然后在组件中使用 html:

  <popup  #popup1>
        Add your custom html elements here
    </popup>
    <button (click)="ClickButton()">show popup</button>

组件:

  @ViewChild('popup1') popup1: Popup;


  constructor() { }

  ClickButton(){
    this.popup1.show();
  }

【讨论】:

    猜你喜欢
    • 2012-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多