2017-10-18 5 views
0

변수에있는 일부 데이터를 인쇄하고 싶습니다. 내가 가진 코드는 다음과 같습니다 그것은 잘 작동하지만 난 이런 식으로 뭔가 얻을데이터를 Angular2로 인쇄하십시오.

public printData(data) { 
     let printContents, popupWin; 
     printContents = data; 
     popupWin = window.open('', '_blank','resizable=yes,top=0,left=0,height=100%,width=auto'); 
     popupWin.document.write(` 
     <html> 
      <head> 
      <title>Print</title> 
      </head> 
      <body onload="window.print();window.close()">${printContents}</body> 
      </html>` 
    ); 
    popupWin.document.close(); 
} 

:

enter image description here

을하고 내가 프린터 옵션 뒤에 창을 원하는 싶지 않아요.

enter image description here

이 작업을 수행 할 수있는 방법이 있나요 : 난 단지 당신이 사용자에게 보여주기를 원하는?

미리 감사드립니다.

+1

당신이 사용을 얻을 수 있습니다 ...이 경우는 window.open 사용하지 않는 기억하는 IFrame을을 사용할 수있는'iframe'이 게시물을 살펴 가지고 https://stackoverflow.com/questions/9616426/javascript-print-iframe-contents-only - 받아 들인 대답은 찾고있는 것일 수도 있습니다 –

+0

시도해 보았습니다. 답변 주셔서 감사합니다. – Yckeb

+0

NP .. 도와 드리겠습니다. –

답변

1

당신은