Here is my code from addevent.ts:
export class EventPage {
eventDetail = {} as EventDetail;
eventDetailRef$: AngularFireList<EventDetail>;
constructor(public navCtrl: NavController, public navParams: NavParams,
private database: AngularFireDatabase) {
this.eventDetailRef$ = this.database.list('event-list');
}
addEvent( eventDetail: EventDetail) {
this.eventDetailRef$.push({
eventName: this.eventDetail.eventName,
eventDesc: this.eventDetail.eventDesc,
lat: Number(this.eventDetail.lat),
lgt: Number(this.eventDetail.lgt)
});
this.eventDetail = {} as EventDetail;
this.navCtrl.pop();
}
}
This is the content of showevent.ts:
newEventListRef$ : AngularFireList<EventDetail>;
newEventList$: Observable<EventDetail[]>;
constructor(public navCtrl: NavController, private database:
AngularFireDatabase) {
this.tabs=["New", "Upcoming"];
this.newEventListRef$ = this.database.list<EventDetail>('event-list');
this.newEventList$ = this.newEventListRef$.valueChanges();
}
And finally, here is showevent.html
<ion-list>
<ion-item *ngFor="let new of newEventList$ | async">
<h2>{{new.eventName}}</h2>
<h4>{{new.eventDesc}}</h4>
<h6>{{new.lat}}</h6>
<h6>{{new.lgt}}</h6>
</ion-item>
</ion-list>
The issue being faced is a TypeError: Object(...) is not a function
The problem arises when trying to retrieve data from Firebase, despite no error showing in VSCode. As a beginner in Ionic 3, I may have made some basic mistakes, so your understanding is appreciated.
Here is the stack trace for reference:
TypeError: Object(...) is not a function
at SwitchMapSubscriber.project (http://localhost:8100/build/vendor.js:78721:76)
at SwitchMapSubscriber._next (http://localhost:8100/build/vendor.js:62701:27)
at SwitchMapSubscriber.Subscriber.next (http://localhost:8100/build/vendor.js:20750:18)
at RefCountSubscriber.Subscriber._next (http://localhost:8100/build/vendor.js:20786:26)
at RefCountSubscriber.Subscriber.next (http://localhost:8100/build/vendor.js:20750:18)
at Subject.next (http://localhost:8100/build/vendor.js:23237:25)
at ConnectableSubscriber.Subscriber._next (http://localhost:8100/build/vendor.js:20786:26)
at ConnectableSubscriber.Subscriber.next (http://localhost:8100/build/vendor.js:20750:18)
at Notification.observe (http://localhost:8100/build/vendor.js:52585:50)
at AsyncAction.DelaySubscriber.dispatch (http://localhost:8100/build/vendor.js:81001:40)