angular - Navigating to a DataURI in angular2 through a function -
i trying call function trigger file download in angular2. data stored in memory of angular2 app (not on server. based on i've read need create data uri here code this.
downloaddata() { let data="bacon,goodness"; let uri = this._sanitizer.bypasssecuritytrusturl("data:text/csv;charset=utf-8," + encodeuricomponent(data)); this.download=uri; window.location.href = uri; }
my issue cannot run command
'window.location.href=uri'
it gives error 'safeurl' not assignable string there way navigate safeurl inside function
i gave on using sanitize. way api allows use safeurl parameter [href]. apparently on purpose security.
i now:
window.location.href = "data:text/csv;charset=utf-8," + encodeuricomponent(data);
Comments
Post a Comment