I am building a large application using AngularJS. The user lands on the login page, and upon login I open up one or two windows. Once open, based on various criteria, the windows will resize, close, or spawn more children. My issue is managing these!
My Angular app can only reference either its direct parent window or windows it has spawned, but not all since the scope is limited to its window. I have tried storing the window objects in localStorage/cookies but that doesn't work due to circular references in the JSON.stringify. I'm at a bit of a loss here on how to structure in a programatic way without hard-coding everything which will not work long term.
I have tried the below obviously, but it won't work because I need to be able to reference any window from any window. And I can't seem to store the var x anywhere.
var x = window.open(...)
- How can I programmatically store and manage (close, open, resize, reposition) multiple windows in my app.
- If an elegant solution does not exist, how can I store & retrieve window objects?
UPDATE
Okay looks like I figured out a way to solve this. I'm storing an array of window IDs in localStorage. Then any time I need to mess with one I read it in, call window.open(null, id).function()
Since window.open returns a reference to the already open window it seems like this should work. Still would love any additional opinions...
Aucun commentaire:
Enregistrer un commentaire