I am trying to implement some PDF Viewer
CodePudding user response:
You should return same data type.Try this method:
base64Subject = new Subject<string>();
//transform subject to observable
$base64 = this.base64Subject.asObservable();
//create a function to change subject value
newBase64(base64:string){
this.base64Subject.next(base64);
}
//Your ngOnInit function will be like this
public ngOnInit(): void {
this.httpClient.get(
'/assets/pdfs/Bootstrap-vs-Material-Design-vs-Prime-vs-Tailwind.base64.txt',
{ responseType: 'text' as 'json' })
.pipe(
tap((base64) => (this.newBase64(base64.Data ""))),
).subscribe();
}
// get base64 data from $base64 when there is a change
this.$base64.subscribe((base64)=>console.log(base64))