如何在home.html中显示AngularFireList

时间:2018-04-02 19:30:57

标签: ionic3 angularfire2

如何在home.html中显示此列表?

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

import { AngularFireDatabase, AngularFireList } from'angularfire2/database';

@Component({
    selector: 'page-home',
    templateUrl: 'home.html'
})
export class HomePage {
    school$ : AngularFireList<any[]>;

    constructor(public navCtrl: NavController, public db: AngularFireDatabase) {
        this.school$ = db.list('/database');

        console.log(this.school$);
    }
}

我试过这段代码,但它没有用

<ion-list>
    <ion-item *ngFor="let data of school$ | async">
        <ion-card>
            <img src="assets/imgs/ensa.png"/>
            <div class="card-title">
                <span>{{data.abrev_school}} </span>
            </div> 
        </ion-card>
    </ion-item>
</ion-list>

enter image description here enter image description here

0 个答案:

没有答案