I'm creating an angular application where, on the home page, I use a controller to do some validation before proceeding with the application login. My question is, do I have to "instantiate" the controllers of each template only when I request that template? I ask this because I do not want to have 1 controllers file with all the controllers because it is illogical in the MVC development pattern and not counting that delays at startup of the application. Putting in a draft ("kicking") I think it would be something like:
Template: registration page
<script src="js/controllers/CadastroCtrl.js"></script>
<ion-view view-title="Cadastro" ng-controller="CadastroCtrl">
<ion-content>
<h1>Cadastre alguma coisa</h1>
</ion-content>
</ion-view>
Template: list page
<script src="js/controllers/ListagemCtrl.js"></script>
<ion-view view-title="Listagem" ng-controller="ListagemCtrl">
<ion-content>
<h1>Liste alguma coisa que foi cadastrada no outro template</h1>
</ion-content>
</ion-view>
Would that be it? Does anyone have a better solution for handling the dependencies of each template? I gave the controller example but if I also have as a dependency some service (factory) or something like that would also fall into this question ...