简体   繁体   English

TypeError:Object(…)不是函数,正在从Firebase调用数据

[英]TypeError: Object(…) is not a function, calling data from firebase

my addevent.ts: 我的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(); 

  }

}

my showevent.ts: 我的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();
}

my showevent.html 我的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>

Problem: TypeError: Object(...) is not a function 问题:TypeError:Object(...)不是函数

i can't call the data from the firebase, there is no redline or error in the VScode, i am very newb to ionic 3, pardon if i make the simplest mistakes. 我无法从Firebase调用数据,VScode中没有红线或错误,我对Ionic 3非常陌生,如果我犯了最简单的错误,请原谅。

Stack trace: 堆栈跟踪:

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)

Please upgrade rxjs in your project, also you have to include rxjs-compat . 请在您的项目中升级rxjs ,并且还必须包括rxjs-compat Try below command to do so: 请尝试使用以下命令来这样做:

npm i rxjs@6 rxjs-compat@6 promise-polyfill --save

Also you have to use subscribe while retrieving list data as follows: 同样,在检索列表数据时,您还必须使用subscribe,如下所示:

this.database.list<EventDetail>('event-list').valueChanges().subscribe((eventData) => 
{ 
  console.log("eventDetails data", eventData);
},(err)=>{
   console.log("Error while retrieving eventDetails : ", err);
}); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在服务中调用 function 并将数据从 Angular 8 [暂停] 上传到 Firebase 集合 - Calling a function in a service and uploading data to a Firebase collection from Angular 8 [on hold] 使用AngularFirestore和firebase的“ ERROR TypeError:Object(…)不是函数” - “ERROR TypeError: Object(…) is not a function” using AngularFirestore and firebase 函数调用firebase对象始终返回true - Function calling firebase object always returns true ionic firebase-TypeError:Object(…)在Firebase.getToken中不是函数 - ionic firebase - TypeError: Object(…) is not a function at Firebase.getToken 从Angular 4组件调用Firebase云功能 - Calling Firebase Cloud Function from Angular 4 Component 在Angular中调用Firebase函数 - Calling a Firebase function in Angular Angular 2从Jquery调用Typescript函数会导致未捕获的TypeError - Angular 2 calling a Typescript function from Jquery causes uncaught TypeError 在调用方法之前,等待数组用Firebase中的数据初始化 - Waiting for array to initialize with data from Firebase before calling methods IONIC 3-TypeError:Object(…)不是函数 - IONIC 3 - TypeError: Object(…) is not a function 未捕获的类型错误:对象(…)不是 function - Uncaught TypeError: Object(…) is not a function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM