【发布时间】:2020-03-06 09:13:33
【问题描述】:
我在 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');}
那是打字稿代码^
【问题讨论】:
-
不要添加代码图片,而是用实际编写的代码替换它们。人们喜欢能够将问题复制并粘贴到他们的本地计算机中,以模拟您面临的问题。
-
@TheFabio 抱歉..我现在已经编写了实际代码
-
console.log(this.years)返回什么?
标签: angular typescript firebase firebase-realtime-database angularfire2