代码:
(转换在两种方法中都不起作用)
1. this.af.database.object('/users/'+key)
.do((something:any)=>console.log(something)) as FirebaseObjectObservable<any>;
2. ..switchMap(()=>this.af.database.object('/users/'+key)) as FirebaseObjectObservable<any>;
问题:
答案 0 :(得分:1)
好的解决了它:
1. <FirebaseObjectObservable<any>>this.af.database.object('/users/'+key)
.do((something:any)=>console.log(something));
2. <FirebaseObjectObservable<any>>..switchMap(()=>this.af.database.object('/users/'+key));
为了替换any
,我在我的用户类中添加了一个$key
属性,所以现在我可以这样做:
1. <FirebaseObjectObservable<User>>this.af.database.object('/users/'+key)
.do((something:any)=>console.log(something));
2. <FirebaseObjectObservable<User>>..switchMap(()=>this.af.database.object('/users/'+key));