如何在Firebase函数中使用组件变量

时间:2017-09-21 04:19:45

标签: javascript angular typescript firebase firebase-realtime-database

来自这个

export class firebaseComponent {

public count: any;

ngOnInit() {
   var ref = this.db.database.ref('/approval');
   ref.limitToLast(1).on('child_added', function( snapShot ) {
      this.count = snapShot.myValue; // Doesn't work
   }
}

我无法使用this.count因为在Firebase中功能不知道什么是this.count

我该如何使用它。我真的希望从Firebase获得价值,以便在HTML中显示{{count}}

0 个答案:

没有答案