Javascript 如何仅在加载某个页面(视图、控制器)时将库注入Angular 1.5应用程序?
我的库相当大,我正在寻找只在需要时加载它的方法 使用名为$ocLazyLoadProvider的机制,例如: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.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/