Created
February 24, 2017 17:42
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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