I got a requirement as following:
There is a link on a web page. As user clicks on link it should create a file on the fly and a download box pops up. How to do it u
decodeRequest(textToDecode) {
var decodedString = atob(textToDecode);
var fileName = "fileName1"+'_RQ';
var fileType = '.xml';
var blob = new Blob([decodedString], { type: fileType });
var a = document.createElement('a');
a.download = fileName;
a.href = URL.createObjectURL(blob);
a.dataset.downloadurl = [fileType, a.download, a.href].join(':');
a.style.display = "none";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
setTimeout(function() { URL.revokeObjectURL(a.href); }, 1500);
}