javascript - HTMLAnchor element download not working in Typescript -
i can't htmlanchor element's download property work under typescript. i'm using following code:
var element = document.createelement('a'); element.href = 'data:attachment/csv,' + encodeuricomponent(csvcontent); element.target = '_blank'; element.mimetype = "attachment/csv"; element.download = 'report.csv'; /* #debug 030314 line fails */ document.body.appendchild(element); element.click();
it seems download property isn't supported in typescript. there work-around, adds .csv suffix file? - possible bypass typescript , call javascript code directly?
you can add yourself:
// tell typescript interface htmlanchorelement{ download:string; } var element = document.createelement('a'); element.href = 'data:attachment/csv,' + encodeuricomponent(csvcontent); element.target = '_blank'; element.mimetype = "attachment/csv"; element.download = 'report.csv'; /* no error on line anymore */ document.body.appendchild(element); element.click();
Comments
Post a Comment