I'm using the bootstrap popup modal window, and trying to $emit and event but for some reason the main page is not detecting the event. It's a pretty simple setup, but I can't figure out why. From what I can tell when viewing Batarang it appears the popup is a child scope of the main app scope so I thought it would work but it doesn't. In this simple app when you press 'ok' in the popup window it should set a value in the parent scope. Here's a plunker:
http://plnkr.co/edit/F2W1LaWSsqinaFpiISAr?p=preview
//Here's code where $emit is called in the child (Factory):
var modalInstance = $modal.open({
templateUrl: 'popupMyWindow.html',
pScope: parentScope,
controller:
function($scope, $modalInstance){
$scope.ok = function () {
$scope.$emit('ModalSelect', 'hello world');
$modalInstance.close(null);
}
},
//Here's where $on is called in the main controller:
$scope.$on('ModalSelect', function (event, selected) {
console.log('ModalSelect called successfully');
$scope.selectedValue = selected;
});
Thanks!