Firebase列表未在运行时显示

时间:2019-08-04 16:07:07

标签: javascript angular firebase firebase-realtime-database angular-services

Angular表示我的功能无法正常工作,但是,在VS Code中,它没有显示任何错误。但是,在运行时无法显示数据库中的项目列表吗?

使用Angular 8和Firebase

画布列表组件

ngOnInit() {
    this.getCanvasList();
  }

  getCanvasList() {
    this.canvasService.getCanvasList().snapshotChanges().pipe(
      map(changes =>
        changes.map(c =>
          ({ key: c.payload.key, ...c.payload.val() })
        )
      )
    ).subscribe(canvases => {
      this.canvases = canvases;
    });
  }

CanvasSerivce.ts

 canvasRef: AngularFireList<Canvas> = null;
 ...
 getCanvasList(): AngularFireList<Canvas> {
    return this.canvasRef;
  }

产生此错误:

ERROR TypeError: this.canvasService.getCanvasList is not a function
    at CanvasListComponent.getCanvasList (canvas-list.component.ts:21)
    at CanvasListComponent.ngOnInit (canvas-list.component.ts:17)
    at checkAndUpdateDirectiveInline (core.js:23869)
    at checkAndUpdateNodeInline (core.js:34427)
    at checkAndUpdateNode (core.js:34366)
    at debugCheckAndUpdateNode (core.js:35388)
    at debugCheckDirectivesFn (core.js:35331)
    at Object.eval [as updateDirectives] (CanvasListComponent_Host.ngfactory.js? [sm]:1)
    at Object.debugUpdateDirectives [as updateDirectives] (core.js:35319)
    at checkAndUpdateView (core.js:34331)

我希望它的输出能够从我的实时数据库中检索项目列表

0 个答案:

没有答案