-1

i'm trying to make pdf viewer on brower with angular,but i got this error?

enter image description here

Error:enter image description here

saad sarhani
  • 39
  • 1
  • 6
  • Welcome to Stack Overflow! Please take the [tour], have a look around, and read through the [help], in particular [*How do I ask a good question?*](/help/how-to-ask) Please post code, error messages, markup, and other textual information **as text**, not as a *picture* of text. Why: http://meta.stackoverflow.com/q/285551/157247 – T.J. Crowder Feb 18 '22 at 16:15
  • In Angular, you shouldn't be using document.getElementById. Strongly suggest you follow at least an Angular basics course (like the Hero tour on the Angular website). – Will Alexander Feb 18 '22 at 16:16

1 Answers1

0

As SOverflow mates said, it would be necessary that you show your code to be able to help you better.

So, while you add it, I will try to give you a solution based on the data you give, trying to "invent" how I think you have it set up.

  1. Try to add a local Reference (#viewer) in your HTML:
<div #viewer>
   <p>Whatever you have in your code div</p>
</div>
  1. Get its value with @ViewChild in your ts, in the AfterViewInit method:
import { Component, OnInit, TemplateRef, ViewChild, AfterViewInit} from '@angular/core';


@ViewChild(‘viewer’) viewer!:ElementRef<HTMLDivElement>
// or, depending on your Angular version: @ViewChild(‘viewer’, {static: false}) viewer!:ElementRef<HTMLDivElement> 

 ngAfterViewInit() {

    // Untill ngAftgerViewInit we don't have ViewChild value
    let pdfViewer = new PDFViewer({
      container: this.viewer;
      viewer: this.viewer;
    })

  }