I'm using Angular 8.
In my service, I'm using a library which accepts callback function and gives value in the callback function.
My service method is
raw(qrInfo, res?): Observable<string> {
return manager.getData(res.width, (res1) => {
return of<string>(res1);
});
}
I want to subscribe to this raw() method and get the result of res1 in the controller
constructor(
private myS: MyService
) {}
data() {
this.myS.raw(info, op).subscribe(res => {
console.log(res); // Get value here
}
}
But this is not working. How can I return observable from callback function?