I have two AngularJs Controllers called "HomeController" and "VacancyController". My HomeController have method getallData(). Below I am trying to call Homecontroller's getallData() function through ng-change event of the dropdown. Please advise how do I call getallData() functiona as my dropdown on-change attribute is wrapped around "VacancyController"?
Below is my code:
HTML
<div ng-controller="VacancyController">
<p>Select a Vacancy:</p>
<select ng-model="selectedVacancy" ng-options="x.name for x in vacancieslist" ng-change=""></select>
<h1>Your selected Vacancy Title is : {{selectedVacancy.name}}</h1>
HomeController
.controller('HomeController', function ($scope, angularSlideOutPanel, $http, $location, $window) {
getallData();
//******=========Get All Teachers=========******  
function getallData() {
    $http({
        method: 'GET',
        url: '/Home/GetAllData'
    }).then(function successCallback(response) {
        // this callback will be called asynchronously
        // when the response is available
        $scope.ListTeachers = response.data;
    }, function errorCallback(response) {
        // called asynchronously if an error occurs
        // or server returns response with an error status.
        $scope.errors = [];
        $scope.message = 'Unexpected Error while saving data!!';
        console.log($scope.message);
    });
};
VacancyController
    app.controller('VacancyController', ['$scope', 'VacancyService', function ($scope, VacancyService) {
    $scope.GetVacancies = function () {
        $scope.vacancieslist = [];
        var getData = VacancyService.Vacancies();
        getData.then(function (ord) {
            angular.forEach(ord.data, function (val) {
                if ($.trim(val).length > 0) {
                    var obj = new Object();
                    obj.name = val.VacTitle;
                    obj.id = val.VacNo;
                    if (val.VacNo > 0) {
                        $scope.vacancieslist.push(obj);
                    }
                }
            });
        }, function () {
            genericService.warningNotify("Error in getting List of Vacancies");
        });
    }
    $scope.GetVacancies();
}]);
 
    