I have following procedure in my AngularJS app to open a text file in a new tab to save:
$scope.createString()
.then(function () {
var windowReference = window.open();
var blob = new Blob([$scope.createdString], { type: 'text/plain' });
var url = (window.URL || window.webkitURL).createObjectURL(blob);
windowReference.location = url;
});
But this does not work. It only opens the same link in a new tab but not the created Blob-Url.
What do I do wrong? How do I accomplish this?
UPDATE:
I accomplished it in IE like this:
$scope.createString()
.then(function () {
var blob = new Blob([$scope.createdString], { type: 'text/plain' });
window.navigator.msSaveOrOpenBlob(blob, 'Test.txt');
});
But is there a standardized way which works with all browsers?