Я импортировал ng2-pdf-viewer и настроил его в соответствии с примером, но получаю сообщение «Ошибка ОШИБКИ: невыполнено (в обещании): Ошибка: ошибки синтаксического анализа шаблона:» ошибка.
Я пытался перенести импорт в home.ts, но это тоже не сработало. Мне действительно нужно это выяснить.
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
<ion-header>
<ion-toolbar>
<ion-title>
NG2-PDF-VIEWER
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<pdf-viewer src="{{pdf}}" original-size="true" show-all="true"></pdf-viewer>
</ion-content>
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 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. ("
<ion-content>
<pdf-viewer [ERROR ->]src="{{pdf}}" original-size="true" show-all="true"></pdf-viewer>
</ion-content>
"): 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. ("
<ion-content>
[ERROR ->]<pdf-viewer src="{{pdf}}" original-size="true" show-all="true"></pdf-viewer>
</ion-content>
"): 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. ("
<ion-content>
<pdf-viewer [ERROR ->]src="{{pdf}}" original-size="true" show-all="true"></pdf-viewer>
</ion-content>
"): ng:///HomePageModule/HomePage.html@9:14
'pdf-viewer' is not a known element: