我已经看过许多其他类似的帖子,但是我仍然不明白问题是什么以及如何解决。
posts$: Observable<Post[]> = this.db
.list(`posts/${this.uid}`)
.do(next => this.store.set('posts', next));
constructor(
private store: Store,
private db: AngularFireDatabase,
private authService: AuthService
) {}
这是我得到的错误:
Property 'do' does not exist on type 'AngularFireList<{}>
这是我的进口货
import { Observable, of } from 'rxjs';
import { tap, filter, map } from 'rxjs/operators';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/map';
import 'rxjs/add/observable/of';
import { AngularFireDatabase } from 'angularfire2/database';
import { AuthService } from '../../../../auth/shared/services/auth/auth.service';
import { Store } from '../../../../store';
最后是package.json中的依赖项
"dependencies": {
"@angular/animations": "^6.0.3",
"@angular/common": "^6.0.3",
"@angular/compiler": "^6.0.3",
"@angular/core": "^6.0.3",
"@angular/forms": "^6.0.3",
"@angular/http": "^6.0.3",
"@angular/platform-browser": "^6.0.3",
"@angular/platform-browser-dynamic": "^6.0.3",
"@angular/router": "^6.0.3",
"angularfire2": "^5.0.0-rc.11",
"bootstrap": "^4.1.2",
"core-js": "^2.5.4",
"firebase": "^5.3.0",
"ngx-bootstrap": "^3.0.1",
"rxjs": "^6.0.0",
"rxjs-compat": "^6.2.2",
"zone.js": "^0.8.26"
},
答案 0 :(得分:0)
看看我刚刚使用的工作代码。
error: Property 'getChildren' does not exist on type 'DataSnapshot'
Also new/correct way for referenceing rxjs
import { Observable, of } from 'rxjs';
import { tap, filter, map } from 'rxjs/operators';
Old incorrect way
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/map';
import 'rxjs/add/observable/of';