last day (15 days later) » 

10:44 AM
0
A: create observable for returning csv values

Fan CheungObservable.create is depreciated. Try the following readDocument(fileChangeEvent: Event) { return new Observable(obs=>{ const file = (fileChangeEvent.target as HTMLInputElement).files[0]; let fileReader = new FileReader(); fileReader.onload = (e) => { obs.n...

 
so, this gives me the observable back as an object. How could I for example console.log the value of the observable something like: console.log(readDocument(data))
 
readDocument(data).subscribe(res=>console.log(res)), updated the answer to handle unsubscription and clean up the callback
 
this works fine with console.log but when i try to use it as a string i get the error: error TS2322: Type 'Subscription' is not assignable to type 'string'. how could I use it as a string?
 
Could u show me how u use it as string?
 
I initialize the string like this: var documentvalue = this.readDocument(data).subscribe(res=>console.log(res));
and i try to use it with highcharts: self.chartOptions.data.csv = documentvalue;
 
10:44 AM
this.readDocument(data).subscribe(res=>console.log(res)) is an async operatio and it returns an subscription, you'll have to assign it inside subscribe, something similar to promise.then()
 
could you add this to your solution?
Hi, thanks so much for your help but i'm still having problems
with your new solution i get this error:
Type 'unknown' is not assignable to type 'string'.ts(2322)
 
11:04 AM
It is hard to debug without the code. Could you setup a simple stackbliz to reproduce it
 
the problem is on line 116
 
11:36 AM
it uses csv data from an input
 
 
2 hours later…
1:23 PM
you can fix the typing error by this.chartOptions.data.csv = newstringvalueforinput as any;
but it looks like the code has other error other than type issue
 
2:05 PM
hi
 

last day (15 days later) »