{"__v":10,"_id":"552e88e32594f70d001b2d0a","category":{"__v":4,"_id":"552e88cf5d4baa0d007836b1","pages":["552e88e32594f70d001b2d0a","552e88ef06a32a0d009c2f8f","552e89055d4baa0d007836b2","552e8a47a702770d00d96e50"],"project":"552d17dea86ee20d00780b89","version":"552d17dea86ee20d00780b8c","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-15T15:50:39.173Z","from_sync":false,"order":1,"slug":"api","title":"API"},"project":"552d17dea86ee20d00780b89","user":"5519ab08eaa2ed2f002135a0","version":{"__v":7,"_id":"552d17dea86ee20d00780b8c","project":"552d17dea86ee20d00780b89","createdAt":"2015-04-14T13:36:30.892Z","releaseDate":"2015-04-14T13:36:30.892Z","categories":["552d17dfa86ee20d00780b8d","552e7d7406a32a0d009c2f7b","552e88cf5d4baa0d007836b1","552e8936a702770d00d96e4d","552e895434565d0d007b4a8d","552e89f82594f70d001b2d0e","552f8a9d8f136c0d005031e9"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":["554584f335b2240d00838952","55d3f70fd2c66f0d00497ffb"],"next":{"pages":[],"description":""},"createdAt":"2015-04-15T15:50:59.259Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"You can configure the service provider `$ocLazyLoadProvider` in the config function of your application:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"angular.module('app', ['oc.lazyLoad']).config(['$ocLazyLoadProvider', function($ocLazyLoadProvider) {\\n\\t$ocLazyLoadProvider.config({\\n\\t\\t// ...\\n\\t});\\n}]);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThe options are:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Option name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Default value\",\n    \"0-0\": \"`debug`\",\n    \"0-1\": \"Boolean\",\n    \"0-2\": \"false\",\n    \"1-0\": \"`events`\",\n    \"1-1\": \"Boolean\",\n    \"1-2\": \"false\",\n    \"2-0\": \"`modules`\",\n    \"2-1\": \"Array of Objects\",\n    \"2-2\": \"*undefined*\"\n  },\n  \"cols\": 3,\n  \"rows\": 3\n}\n[/block]\n\n- `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.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ocLazyLoadProvider.config({\\n\\tdebug: true\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n- `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`.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ocLazyLoadProvider.config({\\n\\tevents: true\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$scope.$on('ocLazyLoad.moduleLoaded', function(e, module) {\\n\\tconsole.log('module loaded', module);\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n- `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.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ocLazyLoadProvider.config({\\n\\tmodules: [{\\n\\t\\tname: 'TestModule',\\n\\t\\tfiles: ['js/TestModule.js']\\n\\t}]\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ocLazyLoad.load('TestModule'); // will load the predefined configuration\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"oclazyloadprovider","type":"basic","title":"Configuration"}
You can configure the service provider `$ocLazyLoadProvider` in the config function of your application: [block:code] { "codes": [ { "code": "angular.module('app', ['oc.lazyLoad']).config(['$ocLazyLoadProvider', function($ocLazyLoadProvider) {\n\t$ocLazyLoadProvider.config({\n\t\t// ...\n\t});\n}]);", "language": "javascript" } ] } [/block] The options are: [block:parameters] { "data": { "h-0": "Option name", "h-1": "Type", "h-2": "Default value", "0-0": "`debug`", "0-1": "Boolean", "0-2": "false", "1-0": "`events`", "1-1": "Boolean", "1-2": "false", "2-0": "`modules`", "2-1": "Array of Objects", "2-2": "*undefined*" }, "cols": 3, "rows": 3 } [/block] - `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. [block:code] { "codes": [ { "code": "$ocLazyLoadProvider.config({\n\tdebug: true\n});", "language": "javascript" } ] } [/block] - `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`. [block:code] { "codes": [ { "code": "$ocLazyLoadProvider.config({\n\tevents: true\n});", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "$scope.$on('ocLazyLoad.moduleLoaded', function(e, module) {\n\tconsole.log('module loaded', module);\n});", "language": "javascript" } ] } [/block] - `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. [block:code] { "codes": [ { "code": "$ocLazyLoadProvider.config({\n\tmodules: [{\n\t\tname: 'TestModule',\n\t\tfiles: ['js/TestModule.js']\n\t}]\n});", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "$ocLazyLoad.load('TestModule'); // will load the predefined configuration", "language": "javascript" } ] } [/block]