The code below was working and it should listen for changes in a node and execute a function but now am getting an error:
ncaught TypeError: Object(...) is not a function
at SwitchMapSubscriber.eval [as project] (changes.js:7)
So, in my angular2
component I have:
private subscriptions = new Subscription();
registered: AngularFireList<any>;
constructor(private _af: AngularFireDatabase){
this.registered = _af.list('/registered');
}
ngOnInit() {
this.subscriptions.add(
this.registered.valueChanges().subscribe(
res => {
console.log("the value has changed");
}
)
);
}
So where am I going wrong as getting the error above which point to:
angular2fire/database/list/changes
What I need my code to do is to listen to whenever there is a change in a firebase node and log to the console
The subscriptions have also been defined by:
private subscriptions = new Subscription();
Adding it to the subscriptions then I can use onDestroy
lifecycle and prevent memory leaks as shown below
ngOnDestroy() {
this.subscriptions.unsubscribe();
}