-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Determine if module is already loaded? #79
Comments
Well there is an undocumented function named if($ocLazyLoad.getModules().indexOf('my.module') > -1) {
// ...
} Otherwhise you can use the same thing that I do in my lib: var isLoaded = false;
try {
isLoaded = angular.module(moduleName);
} catch(e) {
if(/No module/.test(e) || (e.message.indexOf('$injector:nomod') > -1)) {
isLoaded = false;
}
} But if you want I could add a |
+1 for making it available outside. I was looking for the same thing last week and come across several try/catch based solutions. Your internal method with additional regex inside was the prettiest to be fair. |
If it can be useful, I don't see why not. |
Available in master. I'll make a new release soon. |
I'm curious if there's a way to check if a module has already been loaded? I see there's a private function moduleExists() that does this, but it's not accessible from outside the module. Maybe a new method could be exposed to support this, e.g. $ocLazyLoad.isLoaded('my.module')?
My use case is that I need to recompile a directive template after lazy-loading a module containing some UI components. I'd like to set it up so it only does this if the module has not yet loaded.
Thanks!
The text was updated successfully, but these errors were encountered: