我在 Firebase 中有一些记录,我想在我的 HTML 页面上显示这些记录。我附上了数据库的结构。现在,我想以数组的形式显示年份(可点击)。在选择特定年份时,我希望在我的代码中检索相应的记录。
我尝试检索年份,但无法在页面上显示它们。我尝试了一个静态数组,因为 years=["1999","1994"] 有效。只有来自数据库的数据没有被检索和显示。
<div class="list-group " *ngFor="let year of years">
<a routerLink="records" routerLinkActive="active" >
<mdb-icon fas icon="table" class="mr-3"></mdb-icon>{{year}}</a>
</div>
export class NavigationComponent implements OnInit {
@ViewChild('sidenav', {static: true}) sidenav: ElementRef;
//years = ['1999', '2004', '2019'];
clicked: boolean;
resizedImage: Blob;
years:AngularFireList<any[]>;
// TODO: Need to fix the click effect of years
constructor(af:AngularFireDatabase,
private router: Router,
//private userService: UserService
//private ng2ImgMax: Ng2ImgMaxService
) {
this.clicked = this.clicked === undefined ? false : true;
this.years=af.list('/years/Akhilesh');}
那是打字稿代码^
