You can configure the service provider $ocLazyLoadProvider in the config function of your application:

angular.module('app', ['oc.lazyLoad']).config(['$ocLazyLoadProvider', function($ocLazyLoadProvider) {
        // ...

The options are:

Option nameTypeDefault value
modulesArray of Objectsundefined
  • debug: $ocLazyLoad returns a promise that will be rejected when there is an error but if you set debug to true, $ocLazyLoad will also log all errors to the console.
    debug: true
  • events: $ocLazyLoad can broadcast an event when you load a module, a component or a file (js/css/template). It is disabled by default, set events to true to activate it. The events are ocLazyLoad.moduleLoaded, ocLazyLoad.moduleReloaded, ocLazyLoad.componentLoaded, ocLazyLoad.fileLoaded.
    events: true
$scope.$on('ocLazyLoad.moduleLoaded', function(e, module) {
    console.log('module loaded', module);
  • modules: predefine the configuration of your modules for a later use. You will have to specify the name of the module here so that we can find the reference later.
    modules: [{
        name: 'TestModule',
        files: ['js/TestModule.js']
$ocLazyLoad.load('TestModule'); // will load the predefined configuration