i am working on a angular application to export PDF but can't see the data values in exported PDF. my approach: i have 2 components (login,home) ,created a button(export) in login component and which will navigate the user to home component and afterViewInit it will generate the pdf. i wrote the pdf generation code in ngAfterViewInit() lifecycle hook. when i try to await for the response it is not working.
i tried the following 2 ways in home.component.ts
but still nothing is working
ngAfterViewInit(): void {
this.fetchUserData().then(() => {
this.generatepdf();
this.router.navigateByUrl('login');
});
}
async ngAfterViewInit(): void {
await this.fetchUserData();
this.generatepdf();
this.router.navigateByUrl('login');
}
is there a way we can await for the result and generate PDF ?
Expected Result : awaited/fetched response should appear on generated PDF :)