【发布时间】:2019-03-10 04:12:12
【问题描述】:
我正在尝试从数据库中的列表中检索数据并将其显示在我的 Ionic 应用程序中。我的数据库如下:
在我的情况下,我想从数据库内的通知文件夹中检索所有数据并将它们显示在我的应用程序中
我的源代码如下:
home.hmtl
<ion-header>
<ion-navbar color="primary">
<ion-title>
Notifications
</ion-title>
</ion-navbar>
</ion-header>
<ion-content class="background">
<h2>Notifications</h2>
<ion-list>
<ion-item *ngFor="let notification of notifications | async"></ion-item>
{{notification.description}}
{{notification.title}}
</ion-list>
</ion-content>
和 home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { AngularFireDatabase } from 'angularfire2/database';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import firebase from 'firebase';
export class HomePage {
notification:Observable<any>;
constructor(public navCtrl: NavController, public afd: AngularFireDatabase, public http: HttpClient) {
let notification = this.afd.list('Notifications');
}
}
每次在我的 web-explorer("ionic serve") 中运行应用程序时,我都会收到以下错误:TypeError: Cannot read property 'description' of undefined
谁能解释一下我做错了什么? 感谢您的问候
【问题讨论】:
标签: typescript firebase ionic-framework firebase-realtime-database