【问题标题】:error in angular and firebase data retrival角度和火力数据检索中的错误
【发布时间】:2018-07-31 14:53:54
【问题描述】:

这是我的 app.component.ts

import { Component } from '@angular/core';
import { AngularFireDatabase} from 'angularfire2/database';
import {Observable} from 'rxjs/Observable';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html', 
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  student: Observable<student[]>;
  constructor(db: AngularFireDatabase ) {
    this.student = db.list('/student').valueChanges();
    console.log(this.student);
  }
}

显示找不到名字'student'的错误

【问题讨论】:

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


    【解决方案1】:

    看起来您编写的 DB 路径与预期不符。
    尝试将this.student = db.list('/student').valueChanges(); 更改为:

    this.student = db.list('/regestration-student/student').valueChanges();
    如果它是 db 对象的层次结构。

    如果regestration-student 是数据库名称,那么听起来您没有正确注册到数据库。

    另一个选项是:student: Observable&lt;student[]&gt;; 行 对此我不确定。您在哪里声明 student?
    你应该试试FirebaseListObservable&lt;any[]&gt;Observable&lt;any[]&gt;之类的东西

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-06
      • 1970-01-01
      • 1970-01-01
      • 2021-02-03
      • 2016-09-17
      • 1970-01-01
      • 2021-01-19
      • 1970-01-01
      相关资源
      最近更新 更多