Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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'.
window['attr']
declare var window: any;
Try casting window to any like
any
(window as any).attr = "my_value"
Or define type on the top of the component after your imports
Add a comment
Try like this:
Window["attr"] = "my_value";
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
window['attr']2.declare var window: any;on top of the file