Reputation: 4044
This problem is similar to Angular uiRouter open state in new window or tab with stateParams, but the only answer does not seem to work.
I'm displaying a grid where users can select up to 1000 rows. There's a print button which is supposed to open a new tab in the browser with these rows in a printable format.
In my controller, I'm setting these rows (articles) in a service, then I open the new window:
articlesService.setArticles(selected);
$window.open($state.href('newwindow', {}, {absolute: true}), '_blank');
This does open the new tab, however, the data in my service is lost. I'm really supposed to use a new tab. I was thinking about storing the data in a cookie, but as I could have more than 1000 rows, that's not really an option. I'm also not passing anything in the url, as the user can select whatever he wants.
Is there any way to achieve this functionality?
Upvotes: 1
Views: 1458
Reputation: 33149
You need to store data using ngStorage:
http://ngmodules.org/modules/ngStorage
This module enables you to store data in the browser and use it from different tabs and even across sessions; it provides access to the browser's Local Storage in proper Angular fashion. Local storage is a persistent (key, value) tuple storage mechanism.
Upvotes: 1