Ng2-pdf-viewer: Can't bind to 'src' since it isn't a known property of 'pdf-viewer'

Created on 3 Mar 2018  路  7Comments  路  Source: VadimDez/ng2-pdf-viewer

HI,
getting Error where using ng2-pdf-viewer using npm
Description:
using
Ionic framework 3.9
npm 5.6.0
node 8.9.4
angular 4

getting Can't bind to 'src' since it isn't a known property of 'pdf-viewer'
for building for android 7.0
i checked with [email protected] version too
Please help getting error like
'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. ("

[ERROR ->] [src]="pdfSrc" [show-all]="false" [page]="page" (after-load-complete)="afterLoadComplete(")

this is my app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { PdfViewerModule } from 'ng2-pdf-viewer';
import { MyApp } from './app.component';
import { ZoomAreaModule } from '../pages/zoom/zoom-area.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { FileTransfer } from '@ionic-native/file-transfer';
import { FCM } from '@ionic-native/fcm';
import { BackgroundMode } from '@ionic-native/background-mode';
import { HttpModule } from '@angular/http';
import { Network } from '@ionic-native/network';
import { Vibration } from '@ionic-native/vibration';
import { Device } from '@ionic-native/device';
import { DatePicker } from '@ionic-native/date-picker';
import { FilePath } from '@ionic-native/file-path';
import { FileChooser } from '@ionic-native/file-chooser';
import { PdfViewerPageModule } from '../pages/patient-module/pdf-viewer/pdf-viewer.module';

@NgModule({
declarations: [
MyApp,

],
imports: [
BrowserModule,
PdfViewerModule,
BrowserAnimationsModule,
PdfViewerPageModule,
ZoomAreaModule.forRoot(),
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,

],
providers: [
StatusBar,
SplashScreen,
InAppBrowser,
FileTransfer,
FileChooser,
FilePath,
DatePicker,
Device,
Vibration,
Network,
BackgroundMode,
FCM,
{ provide: ErrorHandler, useClass: IonicErrorHandler }
],
schemas:[CUSTOM_ELEMENTS_SCHEMA,NO_ERRORS_SCHEMA]
})
export class AppModule { }

-when running with "ionic cordova run android --prod" and "ionic serve"

stale

Most helpful comment

Hi guys,
Importing the module directly in the component needed (your-page.module.ts) instead of importing it in app.module.ts fixed it for me.
I hope it will help you too !
For example in my case I needed it in my component resto-desc.ts (template = RestoDescPage).
So in resto-desc.module.ts i have the following code :

`import { NgModule } from '@angular/core;
import { IonicPageModule } from 'ionic-angular';
import { RestoDescPage } from './resto-desc';
import { PdfViewerModule } from 'ng2-pdf-viewer';

@NgModule({
declarations: [
RestoDescPage,
],
imports: [
IonicPageModule.forChild(RestoDescPage),
PdfViewerModule,
],
})
export class RestoDescPageModule {}`

All 7 comments

Hi,
Did you get a fix on this issue ? I have the same problem ...
Thanks for your help !

+1

Hi,
did anyone fix this issue?

Hi guys,
Importing the module directly in the component needed (your-page.module.ts) instead of importing it in app.module.ts fixed it for me.
I hope it will help you too !
For example in my case I needed it in my component resto-desc.ts (template = RestoDescPage).
So in resto-desc.module.ts i have the following code :

`import { NgModule } from '@angular/core;
import { IonicPageModule } from 'ionic-angular';
import { RestoDescPage } from './resto-desc';
import { PdfViewerModule } from 'ng2-pdf-viewer';

@NgModule({
declarations: [
RestoDescPage,
],
imports: [
IonicPageModule.forChild(RestoDescPage),
PdfViewerModule,
],
})
export class RestoDescPageModule {}`

Did anyone ever figure this out for Ionic4/Angular 7? I'm getting the same sort of error:

app.module.ts
`import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';

import { PdfViewerModule } from 'ng2-pdf-viewer';

@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, PdfViewerModule],
providers: [
StatusBar,
SplashScreen,
PdfViewerModule,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}`

home.html
`


NG2-PDF-VIEWER




`

home.ts
`import { Component } from '@angular/core';

@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
providers: [ ]
})
export class HomePage {

public pdf;
constructor() {
this.pdf = 'http://www.axmag.com/download/pdfurl-guide.pdf';
}

}`

Error message:
`ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'src' since it isn't a known property of 'pdf-viewer'.

  1. If 'pdf-viewer' is an Angular component and it has 'src' input, 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.
  3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("


]src="{{pdf}}" original-size="true" show-all="true">

"): ng:///HomePageModule/HomePage.html@9:14
'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. ("


[ERROR ->]

"): ng:///HomePageModule/HomePage.html@9:2
Error: Template parse errors:
Can't bind to 'src' since it isn't a known property of 'pdf-viewer'.

  1. If 'pdf-viewer' is an Angular component and it has 'src' input, 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.
  3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("


]src="{{pdf}}" original-size="true" show-all="true">

"): ng:///HomePageModule/HomePage.html@9:14
'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. ("


[ERROR ->]

"): ng:///HomePageModule/HomePage.html@9:2
at syntaxError (compiler.js:2430)
at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:20605)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (compiler.js:26171)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (compiler.js:26158)
at compiler.js:26101
at Set.forEach ()
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:26101)
at compiler.js:26011
at Object.then (compiler.js:2421)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:26010)
at resolvePromise (zone.js:831)
at resolvePromise (zone.js:788)
at zone.js:892
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:17290)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601)`

+1

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

New release causing blank pdf
ShayShaked picture ShayShaked  路  5Comments

2.0.1 no more scrollbar while zooming
Gianlu82b19 picture Gianlu82b19  路  4Comments

I have this error (Angular 8)
GarciaFreelancer picture GarciaFreelancer  路  6Comments

URL scheme "file" is not supported.
manojbhardwaj picture manojbhardwaj  路  7Comments

Is there any way we can read the file from server wherein an authentication is required with JWT?
xyrintech picture xyrintech  路  5Comments