This issue is really frustrating me and I've been stuck on it for hours without finding a solution. I'm hoping someone here can help me out.
Inside my controller.js
file, I have a controller that contains all the information about my page. There's also a button on this page that opens the same page in a new popup window. I'm attempting to call a function in the main window when the user clicks on a button on the popup page.
In my controller.js
:
.controller('rackLayoutController', ['$scope', 'appService', 'rackLayoutService', 'siteService', '$location', '$log', '$sanitize', '$window', '$timeout',
function ($scope, appService, rackLayoutService, siteService, $location, $log, $window, $timeout) {
$( window ).ready(function() {
function refreshPopout(){
$(window).ready(function(){
console.log("readyyyyy");
setTimeout(function () {
window.location.reload();
}, 1000);
});
}
});
$scope.$on('updateRack', function () {
console.log("BROAD 1");
window.opener.refreshPopout();
})
When the user clicks the button, I trigger broadcast updateRack
and while it does log the message correctly as expected, the function itself fails to execute.
The error received is :
TypeError: Object [object global] has no method 'refreshPopout'
Thanks