I recently discovered a great trick using JavaScript to open links without being blocked by popup blockers. You can check out the details here.
With this knowledge in mind, I decided to implement a directive in AngularJS:
.directive('kdExport', function () {
return {
restrict: 'A',
scope: {
options: '=kdExport'
},
controller: 'ExportImageController',
link: function (scope, element, attrs, controller) {
// Handle button click event
element.bind('click', function (e) {
// Prevent default action
e.preventDefault();
// Copy options
angular.extend(controller.options, scope.options);
// Generate the image
controller.generateImage(function (preview) {
// Create URL
var url = '/kits/preview/' + preview.id;
// Open new window
window.open(url, '_blank');
});
});
}
};
})
The issue I encountered was that IE was blocking the link. How can I bypass IE's popup blocker when using this functionality?