How to access global js variable in angular2 component

后端 未结 6 1480
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 10:54

I have a global js variable defined below (@Url is an ASP.Net MVC html helper it will get converted to a string value):



        
6条回答
  •  有刺的猬
    2020-12-03 11:18

    Within your component you could reference window to access the global variables like so:

    rootVar = window["rootVar"];
    

    or

    let rootVar = window["rootVar"];
    

提交回复
热议问题