I am currently working on a project with a model named 'user', which includes a controller called 'login' and a directive called 'userMenu'. My goal is to have the userMenu directive utilize the 'login' controller that already exists within the module. However, I may not have a complete understanding of how modules and directives should interact. Here's what I've attempted so far:
Firstly, I define my controller as shown below:
angular.module('user', []).
controller('login', ['$scope', '$http', function($scope, $http){
$scope.logIn = function(){
//Do something...
}
}
Then, in my directive...
angular.module('user', []).
directive('userMenu', function(){
return {
priority: 0,
templateUrl: 'app/includes/user/menu.html',
replace: true,
restrict: 'A',
controller: 'login',
}
});
However, I encounter the following error message:
Error: Argument 'login' is not a function, got undefined
Could someone provide guidance on utilizing controllers and directives within modules effectively?