Hi -
I am trying to integrate : <a class="postlink" href="https://github.com/VadimDez/ng2-pdf-viewer">https://github.com/VadimDez/ng2-pdf-viewer</a> in my application. I am using angular and core.
core.js:1542 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. ("style/position from the component -->
<pdf-viewer id="viewer" [ERROR ->][src]="pdfSrc" (after-load-complete)="loadComplete($event)"></pdf-viewer>
"): ng:///MainModule/DocumentviewerComponent.html@33:40
'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. ("accordingly and get the style/position from the component -->
[ERROR ->]<pdf-viewer id="viewer" [src]="pdfSrc" (after-load-complete)="loadComplete($event)"></pdf-viewer>
"): ng:///MainModule/DocumentviewerComponent.html@33:16
'createOrEditTemplateModal' is not a known element:
1. If 'createOrEditTemplateModal' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
</div>
[ERROR ->]<createOrEditTemplateModal #createOrEditTemplateModal (modalSave)="getTemplates()"></createOrEditTemp"): ng:///MainModule/DocumentviewerComponent.html@43:4
'viewTemplateModal' is not a known element:
1. If 'viewTemplateModal' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("lateModal #createOrEditTemplateModal (modalSave)="getTemplates()"></createOrEditTemplateModal>
[ERROR ->]<viewTemplateModal #viewTemplateModal></viewTemplateModal>
</div>
"): ng:///MainModule/DocumentviewerComponent.html@44:4
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. ("style/position from the component -->
<pdf-viewer id="viewer" [ERROR ->][src]="pdfSrc" (after-load-complete)="loadComplete($event)"></pdf-viewer>
I have added import { PdfViewerModule } from 'ng2-pdf-viewer'; in app.module.ts.
The component is in the main folder in the angular project.
Am i doing something wrong here ?
4 Answer(s)
-
0
I guess the basic question is where should I import an external component so that I can use it. If you can explain how to work with the below that would be of great help :
<a class="postlink" href="https://github.com/VadimDez/ng2-pdf-viewer">https://github.com/VadimDez/ng2-pdf-viewer</a>
I am kind of stuck here, please help.
-
0
Could you explain a bit more?
What steps did you follow and show some code?
-
0
Code Below :
in app.module.ts :
npm install ng2-pdf-viewer --save
Then added the code to app.module.ts
import { NotificationsComponent } from './shared/layout/notifications/notifications.component'; import { PdfViewerModule } from 'ng2-pdf-viewer';
imports: [ ngCommon.CommonModule, FormsModule, HttpModule, JsonpModule, ModalModule.forRoot(), TooltipModule.forRoot(), TabsModule.forRoot(), FileUploadModule, AbpModule, AppRoutingModule, UtilsModule, AppCommonModule.forRoot(), ServiceProxyModule, TableModule, PaginatorModule, PrimeNgFileUploadModule, ProgressBarModule, PdfViewerModule ],
Then added the component under Main folder in the subfolder : document :
import { Component, Injector, ViewEncapsulation, ViewChild } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Http } from '@angular/http'; import { NotifyService } from '@abp/notify/notify.service'; import { AppComponentBase } from '@shared/common/app-component-base'; import { TokenAuthServiceProxy } from '@shared/service-proxies/service-proxies'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { Table } from 'primeng/components/table/table'; import { Paginator } from 'primeng/components/paginator/paginator'; import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent'; import { FileDownloadService } from '@shared/utils/file-download.service'; import * as moment from 'moment'; @Component({ selector: 'example-app', template: ` <div> <label>PDF src</label> <input type="text" placeholder="PDF src" [(ngModel)]="pdfSrc"> </div> <pdf-viewer [src]="pdfSrc" [render-text]="true" style="display: block;" ></pdf-viewer> ` }) export class PdfviewerComponent { pdfSrc: string = '/pdf-test.pdf'; }
- Made changes to main.module.ts :
import { PdfviewerComponent } from './document/pdf-viewer.component'
declarations: [ DashboardComponent, PdfviewerComponent ]
- Made changes to the routing : main.routing.module.ts
import { PdfviewerComponent } from './document/pdf-viewer.component'
@NgModule({ imports: [ RouterModule.forChild([ { path: '', children: [ { path: 'dashboard', component: DashboardComponent, data: { permission: 'Pages.Tenant.Dashboard' } }, { path: 'document', component: PdfviewerComponent, data: { permission: 'Pages.Tenant.Dashboard' } }, ] } ]) ], exports: [ RouterModule ] })
-
0
Try to add PdfViewerModule to root module's imports;
imports: [BrowserModule, PdfViewerModule],