1

I need to print one of the pages in my Angular app, so I have something like:

myPage = window.open();
myPage.Print();

The thing is that I get the following error from tslint:

"Usage of window is not allowed"

I looked of some answeres here / other solutions, for example: https://brianflove.com/2018/01/11/angular-window-provider/

but they all use at some point window

 return window;

and then I'll get the error messge "Usage of window is not allowed" again.

How can I solve it ?

Thanks.

Hien Nguyen
  • 24,551
  • 7
  • 52
  • 62
Menahem Gil
  • 787
  • 2
  • 15
  • 39
  • https://stackoverflow.com/questions/12709074/how-do-you-explicitly-set-a-new-property-on-window-in-typescript – Sajeetharan Apr 19 '19 at 04:02
  • Possible duplicate of [How do you explicitly set a new property on \`window\` in TypeScript?](https://stackoverflow.com/questions/12709074/how-do-you-explicitly-set-a-new-property-on-window-in-typescript) – v8-E Apr 19 '19 at 05:08
  • Hi, thanks. I looked into these answers, but all of them at some point will have the window word. My tslint pretty much not allows the use of the word window. And I can't change the tslint file. Is there any other way to print the window without the window object? Or get a reference to window without the word window? Thanks – Menahem Gil Apr 24 '19 at 03:57

1 Answers1

0

So I resolved it by instead of do myPage = window.open(); , just do:

myPage = open(); 

instead ...

pretty much so easy.

Menahem Gil
  • 787
  • 2
  • 15
  • 39