【发布时间】:2020-05-28 10:56:52
【问题描述】:
值不显示在页面上,但显示在console.log中
//app.components.ts
import { Component } from '@angular/core';
import {AngularFireDatabase } from 'angularfire2/database';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
posts: any[];
constructor(db: AngularFireDatabase){
db.list('posts').valueChanges().subscribe(posts => { this.posts = posts; console.log(this.posts); });
}
}
//app.component.html
<ul>
<li *ngFor="let post of posts">
{{post.$value}}
</li>
</ul>
//火力基地
【问题讨论】:
-
只做{{post}}
标签: javascript angular firebase firebase-realtime-database