Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何仅在加载某个页面(视图、控制器)时将库注入Angular 1.5应用程序?_Javascript_Angularjs - Fatal编程技术网

Javascript 如何仅在加载某个页面(视图、控制器)时将库注入Angular 1.5应用程序?

Javascript 如何仅在加载某个页面(视图、控制器)时将库注入Angular 1.5应用程序?,javascript,angularjs,Javascript,Angularjs,我的库相当大,我正在寻找只在需要时加载它的方法 使用名为$ocLazyLoadProvider的机制,例如: $ocLazyLoadProvider.config({ 'debug': true, // For debugging 'true/false' 'events': true, // For Event 'true/false' 'modules': [{ // Set modules initially name : 'state1', //

我的库相当大,我正在寻找只在需要时加载它的方法

使用名为$ocLazyLoadProvider的机制,例如:

$ocLazyLoadProvider.config({
    'debug': true, // For debugging 'true/false'
    'events': true, // For Event 'true/false'
    'modules': [{ // Set modules initially
        name : 'state1', // State1 module
        files: ['app/components/state1/state1Module.js']
    },{
        name : 'state2', // State2 module
        files: ['app/components/state2/state2Module.js']
    }]
});

使用它,您可以简单地加载所需的javascript库。您可以加载javascript文件、css文件。

尝试搜索“延迟加载”…更多信息请参见:ciphertrick.com/2016/07/06/lazy-load-modules-and-controllers-in-angularjs/