角JS:加载CSS和JS文件动态 [英] Angular JS: Load CSS and JS files dynamically

查看:186
本文介绍了角JS:加载CSS和JS文件动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发一个Web应用程序的中间。我使用AngularJS动态加载所有文件到用户界面。

1.我有和index.html其上的所有文件都会被动态点击或负载加载。

I am in the middle of developing an web app. I am using AngularJS for loading all the files dynamically into the UI.
1. i have and index.html onto which all the files will be loaded dynamically on click or on load.

    //index.html
    <signin button> <signup button> // etc.,
    //on-clicking signin button a SignIn-page will load in the below div

    <div id="bodyview"></div>
    // end of index.html

现在我的登录页面看起来有点像下面的结构

Now my sign-in page looks somewhat like the below structure

    /*a div where my accordion menu will load when the 
     *below submit button is clicked*/

    <div id="menu"></div>

    //other sign-in-form stuff will follow on...

    //submit button at the end
    <submit button> //only on clicking the submit button the menu will be loaded

现在我的问题是,虽然我能够加载手风琴menu.html文件,我不能加载CSS和JS文件,它依赖。我已经看着大部分计算器的讨论和许多其他的..但没有为我工作。

任何人可以请确定使用 JS角加载CSS和JS依赖的方式帮助 ...?


任何帮助AP preciated。在此先感谢

Now my problem is, though i'm able to load the accordion menu.html file, i'm not able to load the css and js files it is dependent on. I have looked into most of the stackoverflow discussions and many others.. but none worked for me.
Can anybody please help in determining a way for loading the css and js dependencies using Angular JS...?
Any Help is appreciated. Thanks in advance

推荐答案

只写一个服务,CSS和JS文件添加到&LT; HEAD&GT;

Just write a service to add CSS and JS files to the <head>

下面是用于动态加载CSS files.You一个示例服务可以轻松地修改它加载JS文件。

Here is a example service which is used to dynamically load CSS files.You can modify it easily to load JS files.

<一个href=\"https://github.com/Yappli/angular-css-injector\">https://github.com/Yappli/angular-css-injector

这篇关于角JS:加载CSS和JS文件动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆