How to access global js variable in angular2 component

后端 未结 6 1503
佛祖请我去吃肉
佛祖请我去吃肉 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:30

    A different approach would be to export your var, for ex:

      export var API_ENDPOINT = '@Url.Action("Index","Home",new { Area = ""}, null)';
    

    and then import that in your component

    import {API_ENDPOINT }
    

提交回复
热议问题