【问题标题】:How to Load Dynamic Javascript files in index html Angular?如何在 index html Angular 中加载动态 Javascript 文件?
【发布时间】:2017-03-22 12:54:01
【问题描述】:

我现在正在使用 Angular。我在 index.html 中有 2 个 js 文件,问题是我想以动态方式为用户 A 加载一个,为用户 B 加载另一个!如何实现?

提前致谢!

【问题讨论】:

标签: javascript html angularjs


【解决方案1】:
if(userA){
    var file = document.createElement('script')
    file.setAttribute("type","text/javascript")
    file.setAttribute("src", file1)
 }else if(userB){
    var file = document.createElement('script')
    file.setAttribute("type","text/javascript")
    file.setAttribute("src", file2)
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-20
    • 1970-01-01
    • 2017-10-27
    • 2018-08-05
    • 1970-01-01
    • 2014-10-13
    • 2016-10-05
    相关资源
    最近更新 更多