I've made 2 controllers, one for the actual page and one for a success modal. I am broadcasting an even from the modal controller and listening to the even in the page controller. I'm using 'this' to refer to the current instance of the scope variable. But in the $on listener, whenever I try to use the scope variable, it is found null and due to this I cannot modify the page controller variables.
On page controller:
$rootScope.$on('backToFetch', function() {
for(var i=0; i < this.fetchUploader.documentData.length; i++) {
this.fetchUploader.documentData[i].isSuccess = false;
this.fetchUploader.progress = 0;
}
deleteFormFields()
});
On modal controller:
$rootScope.$broadcast('backToFetch');
How can I get the reference of the scope variable inside the $on listener