TypeError:Object(...)不是函数 [英] TypeError: Object(...) is not a function
问题描述
使用ionic3,angularfire2 v5
working on ionic3, angularfire2 v5
TypeError:对象(...)不是SwitchMapSubscriber的函数
。项目( http:// localhost:8100 / build / vendor.js:73935:76 )SwitchMapSubscriber._next上的
( http:// localhost:8100 /build/vendor.js:61778:27 )
在SwitchMapSubscriber.Subscriber.next( http:// localhost:8100 / build / vendor.js:20750:18 )
at RefCountSubscriber.Subscriber._next( http:// localhost:8100 / build / vendor.js:20786:26 )
在RefCountSubscriber.Subscriber。下一步( http:// localhost:8100 / bu ild / vendor.js:20750:18 )在Subject.next的
( http:// localhost:8100 / build / vendor.js:23237:25 )
在ConnectableSubscriber.Subscriber._next( http:// localhost:8100 / build / vendor.js:20786:26 )
at ConnectableSubscriber.Subscriber.next(< a href =http:// localhost:8100 / build / vendor.js:20750:18 =nofollow noreferrer> http:// localhost:8100 / build / vendor.js:20750:18 )Notification.observe上的
( http:// localhost:8100 / build / vendor.js:51866:50 )AsyncAction.DelaySubscriber.dispatch的
( http:// localhost:8100 / build / vendor.js:76246:40 )
TypeError: Object(...) is not a function at SwitchMapSubscriber.project (http://localhost:8100/build/vendor.js:73935:76) at SwitchMapSubscriber._next (http://localhost:8100/build/vendor.js:61778: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:51866:50) at AsyncAction.DelaySubscriber.dispatch (http://localhost:8100/build/vendor.js:76246:40)
home。 ts
import { Component } from '@angular/core';
import {IonicPage, NavController} from 'ionic-angular';
import { Observable } from "rxjs/Observable";
import { Item } from "../../models/item/item.model";
import {ShoppingListServices} from "../../services/shopping-list/shopping-list.services";
@IonicPage()
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
shoppingList$: Observable<Item[]>;
constructor(public navCtrl: NavController, private shopping: ShoppingListServices) {
this.shoppingList$=this.shopping
.getShoppingList()
.snapshotChanges()
.map(
changes => {
return changes.map(c => ({
key: c.payload.key, ...c.payload.val()
}));
}
);
}
}
home.html
home.html
<ion-header>
<ion-navbar color="primary">
<ion-title>
Shoping List
</ion-title>
<ion-buttons end>
<button navPush="AddShoppingItemPage" ion-button>
<ion-icon name="add"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-list-header>
Items
</ion-list-header>
<ion-item *ngFor="let item of shoppingList$ | async">
{{ item.name }}
</ion-item>
</ion-list>
</ion-content>
推荐答案
这适用于我,使用angularfire2:^ 5.0.0-rc.11
npm i rxjs@6 rxjs-compat@6 promise-polyfill --save
要检索数据:
this.db.list('/customers').valueChanges().subscribe((datas) => {
console.log("datas", datas)
},(err)=>{
console.log("probleme : ", err)
});
或者你可以查看GitHub存储库中的angularfire2 这里了解更多详情
Or you can check the GitHub repository for angularfire2 here for more details
这篇关于TypeError:Object(...)不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!