Skip to content

Instantly share code, notes, and snippets.

@fidian
Created February 24, 2017 17:42
Show Gist options
  • Save fidian/74556073e133292aa327dd5c7da21dee to your computer and use it in GitHub Desktop.
Save fidian/74556073e133292aa327dd5c7da21dee to your computer and use it in GitHub Desktop.
Are you getting a totally unhelpful message from Angular saying it has a problem loading a module?
/**
* So I have had a bugger of a time figuring out what dependency fails and
* exactly how that module is required. This function will do that search
* for you. Simply open up the browser's console, copy and paste in the function,
* then call it with the name of the module you expect to run.
*
* Sample:
*
* checkAngularModuleDependencies("app")
*
* Results are written to console.
*/
function checkAngularModuleDependencies(name, parent) {
try {
if (angular.module(name).requires.every(function (child) {
return checkAngularModuleDependencies(child, name);
})) {
if (! parent) {
console.log("All modules seem loadable.");
}
return true;
}
console.error(" ... included by " + name);
} catch (e) {
console.error("Unable to find module " + name);
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment