ocLazyLoad
ocLazyLoad copied to clipboard
moduleLoaded / moduleReloaded events not fired
Hi, great library, this does exactly what I need, but haven't been able to use the moduleLoaded/moduleReloaded events.
I define a module comprising multiple files, see all files loaded, see individual fileLoaded events, but no moduleLoaded event - is this a known issue?
The bower.json file reports version 1.0.9.
+1. Experiencing the same. fileLoaded is not firing as well.
Hmm Ok I'll check that :)
thanks; fileLoaded working fine, only issue is moduleLoaded.
@ams10961 fileLoaded events didn't fire for me. However, I turned on debug as true in config. It did spit the fileLoaded events on the console. Can you post an example code of how you got that to work. Here is what I had for the listener :
$scope.$on('ocLazyLoad.fileLoaded',function(e,file)
{
});
Can you try with $rootScope instead of $scope ?
Didn't work either. Same behavior.
@ocombe just tried with the following in my controller, didn't seem to pick up an event; var $rootScope = $injector.get('$rootScope');
// tried moduleLoaded too
$rootScope.$on('ocLazyLoad.moduleReloaded', function(e, module) {
$log.debug('module reloaded:' + module);
});
@sfdeveloperhub this is my app config function
$ocLazyLoadProvider.config({
events: true,
modules: [{
name: 'module1',
files: ['file1.js','file1.css']
}, {
name: 'module2',
files: ['file2.js','file2.css']
}]
});
in the run function
$ocLazyLoad.load('module1');
then in a controller
$scope.$on('ocLazyLoad.fileLoaded', function(e, file) {
$log ('file loaded:'+file);
});
all working well.
hi.. I wondered if you had any thoughts on where to look for this; I need to load 4 files and then act after the final one has loaded; I had a quick check of the source code, saw that ocLazyLoad.core.js:192 seems to broadcast the module loaded event, but can't see it triggered when I load from a module.. thanks..
How will you load the module ? If you use the service then it returns a promise and you can chain with then(function() { ... })
hi.. thanks, I used this approach and worked around it. The odd thing is that I didn't notice the load module event thrown when I enabled debug mode. The broadcast function (ocLazyLoad.core.js:353) looks like it should log an event being thrown.
Seems like this issue has been resolved right? I'd love it if we could help @ocombe to keep the issue number down by letting him know when the issue can be closed.
I think the issue has only been worked around, not resolved..