0
在我的Angular 2應用程序中,我需要傾聽表格以瞭解Firebase
中的更改。我正在使用Angular2,Firebase和TypeScript。我有一個監聽器,但當我更改數據庫表時它不會觸發。需要聽Firebase中的更改
我需要它在表更新/更改時總是碰到聽衆。 看來我需要把我的聽衆放在全球的地方。目前,我的監聽器位於一個服務文件中。
這是我的嘗試:
this.adminNotifications = new Firebase(_environment.firebaseUrl + "/adminNotifications");
taskSchedulerListner =(): Promise<any> => {
this.adminNotifications.on('value', function(snapshot: any) {
console.log("admin notification hit!");
});
}
讓我知道如果你需要看到任何其他代碼。目前,我只希望在更改表格時更改了管理通知。換句話說,我想在上面的例子中使用console.log
方法。
我沒有得到任何控制檯錯誤,只是當表adminNotifications改變時沒有任何反應。