我无法显示数据库中的特定元素。
//component.html
<section class="firee">
<figure class="snip1208">
<div *ngFor="let scholarship of scholarships" >
<h3>{{scholarship.title}}</h3>
<p>{{scholarship.description}}</p>
</div>
</figure>
</section>
//component.ts
import { Component, OnInit } from '@angular/core';
import {AngularFireDatabase} from 'angularfire2/database';
@Component({
selector: 'app-scholarship',
templateUrl: './scholarship.component.html',
styleUrls: ['./scholarship.component.css']
})
export class ScholarshipComponent implements OnInit {
scholarships: any[];
constructor(db: AngularFireDatabase){
db.list('scholarships')
.valueChanges()
.subscribe(scholarships => {
this.scholarships = scholarships;
console.log(this.scholarships); });
}
ngOnInit(): void {
}
}
正在工作
但是例如当我放的时候
<div *ngFor="let scholarship of scholarships" >
<h3>{{scholarship.3}}</h3>
</div>
无效。我也尝试过使用“ first_post”,但也不起作用
<h3>{{scholarship[3].title}}</h3>
或
<h3>{{scholarship["3"].title}}</h3>