I have a $scope.$on callback function in my mainController. It works perfectly whenever I call it from each controller, but when I call it from a modalController after opening the modal, it doesn't work:
define(['app', 'jquery'], function (app, $) {
app.controller('MainViewControllerUser',
function ($scope, $location, $rootScope, $interval, MainViewFactoryUser){
$scope.$on('loadingPage', function (event, value) {
$scope.chartLoading = value;
});
}
});
//----------------------- end of main Controller
define(['app', 'underscore'], function (app, _) {
app.controller('advertisementController',
['$scope', '$location', '$rootScope', '$interval', 'toaster', 'advertisementFactory', '$modal',
function ($scope, $location, $rootScope, $interval, toaster, advertisementFactory, $modal) {
$scope.$emit('loadingPage', true);
}
]);
app.controller('addClientCrtl',
['$scope', '$modalInstance', 'toaster', 'advertisementFactory',
function ($scope, $modalInstance, toaster, advertisementFactory)
{
$scope.$emit('loadingPage', true);
}
]);
});
The
$scope.$emit('loadingPage', true);
in the advertisementController works well, but in addClientCrtl it's not working. It's worth mentioning that the modal controller is defined in the adviertisementController and called inside it.