Reputation: 684
I have an $scope.$on callback function on my mainController. wherever I call it from each controller it works perfectly. but when I call it from a modalController after opening modal , it's not working:
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);
}
]);
});
that $scope.$emit('loadingPage', true);
in the advertisementController is working nice but in addClientCrtl not working. I have to quote that modal controller is defining in adviertisementController and calling inside it
Upvotes: 0
Views: 107
Reputation: 7734
Instead of $scope can you try $rootScope:
$rootScope.$on('loadingPage', function ({
});
$rootScope.$emit('loadingPage', true);
Upvotes: 2