In the index.php file I include all controllers:
<script src="app/app.js"></script>
<script src="app/ctrl_A.js"></script>
<script src="app/ctrl_B.js"></script>
<script src="app/ctrl_C.js"></script>
//etc...
This is not good, since I am loading javascript files that are not missing, for example, on the homepage.
In the .config of the app I'm referring to the controller as follows:
app.config(['$urlRouterProvider', '$stateProvider', '$locationProvider',
function($urlRouterProvider, $stateProvider, $locationProvider) {
$urlRouterProvider.otherwise("/login");
$stateProvider
.state('login', {
url: "/login",
templateUrl: "view/login.html",
controller: 'ctrl_A'
})
//...
How do I make the dependencies (controller, factory, directive, ect ...) dynamically loaded without declaring in index.php?