Ng2-pdf-viewer: Pdf-viewer is not a angular component

Created on 1 Apr 2017  路  15Comments  路  Source: VadimDez/ng2-pdf-viewer

after updating angular 2 rc5 to angular 2.4 pdf-viewer gives an error that is not a angular component
error

All 15 comments

Check your configuration it seems like you didn't add ng2-pdf-viewer to your app

@VadimDez, why PdfViewer isn't a angular module?

same error ([email protected], [email protected],[email protected])

From my appModule.ts:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { RouterModule, RouteReuseStrategy } from "@angular/router";
import { PdfViewerComponent } from "ng2-pdf-viewer";
....
declarations: [
            AppComponent,
            PdfViewerComponent,
...

From my component:

```
import {Component, ViewChild} from "@angular/core";
import {Route, ActivatedRoute} from '@angular/router';
import { BibliographyServices } from "../services/bibliographyServices";
import { JournalArticle } from "../models/Bibliography";
import 'rxjs/Rx'; //for map function
import { PdfViewerComponent } from "ng2-pdf-viewer";

@Component({
selector: "pdf-edit-component",
templateUrl: "./pdfEditComponent.html",
host: { class: "pageComponent" }
})

export class PdfEditComponent {
public pdfSrc: string = 'https://vadimdez.github.io/ng2-pdf-viewer/pdf-test.pdf';
page: number = 1;

constructor(public pdfViewerComponent: PdfViewerComponent, private bibliographyService: BibliographyServices, private route: ActivatedRoute) {
}

...

And my html page:





[page]="page"
[original-size]="true"
style="display: block;"

```

I don't see if I'm forgetting something

In case it is related, I installed ng2-pdf-viewer after an angular update, and compiler warms about problems in zone.js and in jquery, I supose relating to angular package.json versions. I update both modules from github so. If I comment the pdf-viewer element in html, the application is fine.

i have the same issue....

+1 Same Issue

any timeline???
thank you.

Could anybody show me how to reproduce it? Tried myself got no problems.

@ces10 your problem is that you doing something that you shouldn't, Remove public pdfViewerComponent: PdfViewerComponent from

constructor(public pdfViewerComponent: PdfViewerComponent) {}

@VadimDez Many thanks, it works!

ERROR Error: Uncaught (in promise): Error: Template parse errors:
'pdf-viewer' is not a known element:

  1. If 'pdf-viewer' is an Angular component, then verify that it is part of this module.
  2. If 'pdf-viewer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("dth: 150px;height: 200px;" >

    click me to view PDF in Iframe!


    [ERROR ->]



"): ng:///SelfModule/EditComponent.html@305:16

--

Please help me

@balamca7 here's documentation: https://github.com/VadimDez/ng2-pdf-viewer
see how to integrate it in your project there.

@VadimDez
yes i follow this document, but get this error.
I am using angular version 4.

@balamca7 the error that you've sent before is saying that component is not found - means that you imported PdfViewerModule in the wrong place or imported it wrongly.

For anyone else, I had this problem when I had a module for my page component, and I had added the PdfViewerModule import in app.module.ts instead of my page-level module.ts. I moved the PdfViewerModule import to my page-level module.ts.

I was having this issue even with the import in the sub-module. I'm not sure which of these things did the trick, but I closed VS Code, did npm install, reran ng build --watch, then opened VS Code again.

I was having this issue, I checked all the possible solutions, but in vain. I was opening a mat dialog from component and showing pdf in that mat dialog, then this error is coming "Pdf-viewer is not an angular component". I tried adding Pdfviewer at the app module, page module but did not work, then I checked the module file and found out that I have not added the mat dialog component in my main module file i.e this error. I added a mat dialog component in my module and everything works fine.

So, please check things carefully, the problem might be somewhere else, not in this pdf viewer module.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Invalid 'reference' directive syntax
roginneil picture roginneil  路  3Comments

Can't bind to 'src' since it isn't a known property of 'pdf-viewer'
yashwanth493 picture yashwanth493  路  7Comments

PDFDocumentProxy, PDFProgressData are undefined for compiler
VadimDez picture VadimDez  路  5Comments

Zoom in document
quentinmachard-niji picture quentinmachard-niji  路  3Comments

Cannot read property 'sendWithPromise' of null error
fncamm picture fncamm  路  4Comments