I'm decoupling some components and I'm not sure when to create a controller linked to the template.
I have for example the Login screen, in my directive I do:
app.directive('appLogin',function(){
return{
scope: {},
restrict:'E',
templateUrl:'view/usuario/login.html',
controller: ['$scope', function($scope) {
console.log($scope.login);
}],
};
});
In this way I can get all values from the login screen and perform some action, I would like to do a separation to leave like this:
app.directive('appLogin',function(){
return{
scope: {},
restrict:'E',
templateUrl:'view/usuario/login.html',
controller: 'controller/usuario/login.js'
};
});
This way I would only include 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 1 for View.