I have been tackling this issue for a long time with great difficulty since there are a lot of articles that show how to load directives, services, and other angular components that use the word module to describe them.. ending up with an SEO nightmare.
All the solutions are incredibily complex, making dividing the JS files almost not relevant.
Has someone found a simple way to inject an angular module dependency to the main module when it's needed ?
Note: since I'm using require.js the actual JS is already present (also lazyloaded just when it's needed). So all that really is needed is to inject the modules onto angular.
Here is how close I got:
window function in index.html to load the secondary .js file