I'm trying since few hours to call a function from a controller to another controller.
I saw similar topics (I tried but I'm certainly too bad): What's the correct way to communicate between controllers in AngularJS? Can one controller call another?
But no concrete example like I'm looking for.
Controllers:
app.controller('Controller1', function($scope, $modal, $modalInstance, job, JobServices) {
$scope.job1 = function () {
JobServices.job1($scope.name)
.success(function(data, status, headers, config) {
// something
});
}
function doSomething(){
// How call test() from controller2 ?
}
}
app.controller('Controller2', function($scope){
function test(){
do a lot of things
}
}
What's the best and easiest way to do that ?
Thank you a lot
EDIT:
I already tried using something like that:
app.controller('Controller1', ['$scope', '$rootScope', function($scope, $rootScope, $modal, $modalInstance, job, JobServices) {
But I have error saying job1 is undefined...