saad sarhani
saad sarhani

Reputation: 39

Argument of type 'HTMLElement' is not assignable to parameter of type 'HTMLDivElement'

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

Upvotes: -1

Views: 1495

Answers (1)

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;
    })

  }

Upvotes: 0

Related Questions