2

Can I add any attribute to 'window' object in Angular? Some thing like:

window.attr = "my_value"

I try tu use the object windows bat have the error:

Property 'attr' does not exist on type 'Window'.

mbojko
  • 13,503
  • 1
  • 16
  • 26
Phil
  • 43
  • 1
  • 6

2 Answers2

2

Try casting window to any like

(window as any).attr = "my_value"

Or define type on the top of the component after your imports

declare var window: any;
jitender
  • 10,238
  • 1
  • 18
  • 44
2

Try like this:

 Window["attr"] = "my_value";
Adrita Sharma
  • 21,581
  • 10
  • 69
  • 79