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

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -