意外指令|请添加@NgModule批注

时间:2018-11-29 02:05:23

标签: firebase-realtime-database angularfire angular-cli-v7

我不明白为什么它认为没有注释...我想念什么?请帮忙。我的目标是从基于火力的存储中呈现PDF文档。我面临着完成这项工作的压力,需要一些指导。

我在此处添加了相关代码,供您查看和了解,希望有人能为我提供帮助。

模块

import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { PdfViewerComponent } from 'ng2-pdf-viewer';
import { PdfService } from '../core/pdf.service';

@NgModule({
    imports: [
      CommonModule,
      PdfViewerComponent
    ],
    declarations: [ PdfViewerComponent],
    exports: [PdfViewerComponent],
    providers: [PdfService],
    schemas: [CUSTOM_ELEMENTS_SCHEMA],

  })
  export class PdfModule { }

HTML

<div class="pdf"> Hello PdfComponent! 
<div>
    <label>PDF src</label>
    <input (change)="OnFileSelected($event)" type="file" id="file" >
    <input [(ngModel)]="page" type="text" id="page" >{{ uploadProgress | async }}</div>
    <br>
  <div class="progress">
    <div class="progress-bar progress-bar-striped bg-success" role="progressbar" [style.width]="(uploadProgress | async) + '%'"[attr.aria-valuenow]="(uploadProgress | async)" aria-valuemin="0" aria-valumax="100">
    </div>
    <div *ngIf="downloadURL | async; let downloadSrc " class="alert alert-info" role="alert">
      File Uploaded: <a [href]="downloadURL | async">{{ downloadSrc | async }}</a>
    </div>
      <br>
  <pdf-viewer [src]="pdfSrc"
            [render-text]="true"
            [page]="page"
            [show-all]="true"
            style="display: block;"
  ></pdf-viewer></div>

组件

    constructor(private _service: PdfService, private db: AngularFireDatabase,
      private storage: AngularFireStorage, public pdfViewerComponent: PdfViewerComponent) {

      }

    ngOnInit() {
    }

    OnFileSelected(event) {
      const img: any = document.querySelector('#file');
      this.pdfSrc = this.pdfViewerComponent.pdfViewer(this.ref = this.afStorage.ref(img));

      if (typeof (FileReader) !== 'undefined') {
        const reader = new FileReader();

        reader.onload = (e: any) => {
          this.pdfSrc = e.target.result;
          this.task = this.afStorage.upload(img, event.target.dispatchEvent[0]);
              const downloadUrl = this.ref.getDownloadURL().toPromise();
              this.db.list('images').push({downloadUrl});
              console.log(downloadUrl, 'url');
            };

        reader.readAsArrayBuffer(img.files[0]);
        console.log(this.downloadUrL, 'url');
    }
  }

0 个答案:

没有答案