ionic3 - TypeError: Object(...) 不是函数
问题描述
致力于 ionic3、angularfire2 v5
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)
主页.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()
}));
}
);
}
}
主页.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 以获取更多详细信息
推荐阅读
- ios - iOS:以编程方式将通知设置从“从不请求”更改为“拒绝”
- android - 无法为 react-native 项目生成发布 apk
- sql - 如果我通过日期,即 20/04/2020,为什么程序会抛出错误?
- asp.net - 为什么 Page.PreviousPage 超时,是 sessionState 超时还是别的什么?
- postgresql - 更新 PostgreSQL 中 JSONB 字段中的嵌套属性
- python-3.x - 无法在 Windows 上启动 Jupyter Notebook
- android - 使用 Android 信标库查找设备到 Eddystone 信标的距离
- ios - ionic cordova 语音识别插件在 android 上运行良好,但在 ios 上失败
- google-cloud-platform - howto:超时后重新启动守护程序服务?
- python - 哪个是最简单(最快且可能不安全)的可逆固定大小保长对称密码学?