【发布时间】:2018-10-27 12:25:42
【问题描述】:
我已成功更新 angularfire 5.0.0.rc 8 和 firebase 5.0.2,没有错误模块。我想我要做的最后一件事是更改此代码以检索所有数据
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { IonicPage } from 'ionic-angular/navigation/ionic-page';
import { Observable } from 'rxjs';
import 'rxjs/add/operator/map';
import { Note } from '../../model/note/note.model';
import { NoteListService } from '../../services/note-list.service';
@IonicPage()
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
noteList: Observable<Note[]>
constructor(public navCtrl: NavController, private noteListService: NoteListService) {
this.noteList = this.noteListService.getNoteList()
.snapshotChanges()
.map(
changes => {
return changes.map(c => ({
key: c.payload.key, ...c.payload.val()
}))
});
}
}
noteListService 的文件...
import { Injectable } from '@angular/core';
import { AngularFireDatabase } from 'angularfire2/database';
import { Note } from '../model/note/note.model';
@Injectable()
export class NoteListService {
private noteListRef = this.db.list<Note>('note-list');
constructor(private db: AngularFireDatabase) { }
getNoteList() {
return this.noteListRef;
}
addNote(note: Note) {
return this.noteListRef.push(note);
}
updateNote(note: Note) {
return this.noteListRef.update(note.key, note);
}
removeNote(note: Note) {
return this.noteListRef.remove(note.key);
}
}
帮助更改与我的新版本 angularfire 5.0.0 rc 8 和 firebase 5.0.2 兼容的代码
这是我的一半代码正常工作后出现的新错误。插入部分。 但我仍然无法查询
Runtime Error Uncaught (in promise): TypeError: this.noteListService.getNoteList(...).snapshotChanges(...).map is not函数类型错误: this.noteListService.getNoteList(...).snapshotChanges(...).map 不是 新主页 (http://localhost:8100/build/0.js:86:14) 上的功能 createClass (http://localhost:8100/build/vendor.js:10575:20) 在 创建指令实例 (http://localhost:8100/build/vendor.js:10458:20) 在 createViewNodes (http://localhost:8100/build/vendor.js:11680:36) 在 createRootView (http://localhost:8100/build/vendor.js:11594:5) 在 callWithDebugContext (http://localhost:8100/build/vendor.js:12629:25) 在 Object.debugCreateRootView [as createRootView] (http://localhost:8100/build/vendor.js:12116:12) 在 ComponentFactory_.create (http://localhost:8100/build/vendor.js:9938:29) 在 ComponentFactoryBoundToModule.create (http://localhost:8100/build/vendor.js:3914:29) 在 NavControllerBase._viewInit (http://localhost:8100/build/vendor.js:49286:44) 堆 错误:未捕获(承诺):TypeError:this.noteListService.getNoteList(...).snapshotChanges(...).map 不是 一个函数
【问题讨论】:
-
如果没有确切的错误,我们无法帮助您。暂停您的问题,直到您能够发布确切的错误
-
更新错误.. 你在运行 rc.8 版本的 angularfire2
-
您需要分享参与其中的完整代码。就像这个:this.noteListService.getNoteList()
-
请帮帮我;(。自从 4 天以来,我一直被那些离子错误所困扰。这是最后一个
标签: angular firebase ionic3 angularfire2