Reputation: 507
I have been working on an angular application. I have one requirement while where I show list of available tasks to user and clicking on a particular task, open a new window with the same AngularJS application code base, which will allow the user to make changes to the task. The application in new window will be independent and user can perform some actions. Once user closes the window, I need refresh the task list in parent application (parent window).
I am passing some data to child window, the data consist of some properties and one function,
var appData = {
action: "edit",
id: taskId,
refreshTasks: refreshTasks
};
Refresh task is a method in my one of the controller
I am passing the data to the child window in following manner,
var windowHandle = $window.open("http://www.example.com");
if(angular.isDefined(windowHandle)) {
windowHandle.appData = (dataObj == null ? {} : dataObj);
windowHandle.appData.isChildWindow = true;
}
Now we access the passed data in child window using,
$window.appData
Now when child window closes, I am invoking my passed function in following manner,
$window.appData.refreshTasks()
The above seems to work in Chrome and Mozilla but its not working in IE (8,9,10,11)
So I really wanted to know how I can call function from one angular application in one window to another angular application in another window.
Can you kindly let me know what is the correct way to do this ?
Upvotes: 3
Views: 1400
Reputation: 4099
You can access the appData
using window.opener
:
window.opener.appData
window.opener.appData.refreshTasks()
Upvotes: 1