1
I am decommissioning some components and I am in doubt when creating a controller linked to the template.
I have for example the Login screen, in my Directive do:
app.directive('appLogin',function(){
return{
scope: {},
restrict:'E',
templateUrl:'view/usuario/login.html',
controller: ['$scope', function($scope) {
console.log($scope.login);
}],
};
});
This way I can take all the values of the login screen and perform some action, I would like to perform a separation to leave so:
app.directive('appLogin',function(){
return{
scope: {},
restrict:'E',
templateUrl:'view/usuario/login.html',
controller: 'controller/usuario/login.js'
};
});
This way I would include only one init.js file in index.html and it would load all the modules and controllers I need.
What am I doing wrong? Is this the right way to perform angular modularization? I am separating 1 file for Controller and one for View.
I’m doing this, just adding the controller name, but it would be nice if it could include the file controller on demand
– Gabriel Rodrigues
The problem with this is that, for example, when using a file . min there would be many other controllers. What you can do is include the module via require or other service. I particularly use $ocLazyLoad that works great with ui-router, so I can load modules along the navigation and use as needed.
– celsomtrindade