How to set viarable as a global property?

When I get the useId, I want to set it as a global property, how do I do it?

@wenqi Usually you would create something like a UserService for that which can be injected and holds onto the user ID for you. Alternatively you can also simply store the property on the window object, which is globally available (in the frontend).

How to add a property on windows? window.userInfo = xxx, you can’t add properties on windows, can you give me an example?

@wenqi as JavaScript is a dynamic language you should always be able to add properties to any object. TypeScripts probably just prevents you from doing that. A quick workaround would just be (window as any).userInfo = "...".

thank you very much