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'.

1
  • To ways to do it 1. window['attr'] 2. declare var window: any; on top of the file Commented Oct 10, 2019 at 12:08

2 Answers 2

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;
Sign up to request clarification or add additional context in comments.

Comments

2

Try like this:

 Window["attr"] = "my_value";

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.