如何从 AngularFire2 中的 BehaviorSubject 获取当前值?
How to get current value from a BehaviorSubject in AngularFire2?
我正在使用 AngularFireDatabase 来获取我的数据库的一部分,就像这样 db.object('/accounts/'+this.cid);
其中 this.cid
是一个可以更改的 BehaviorSubject
。我是不是用错了方法?
cid: BehaviorSubject<string>;
account: FirebaseObjectObservable<any>;
constructor(private db: AngularFireDatabase) {
this.cid = new BehaviorSubject<string>('fs2ejD4ds');
this.account = db.object('/accounts/'+this.cid);
基本上每当我 运行 this.cid.next('fhEj2jd')
我希望它改变我们试图在 Firebase 中引用的对象。
我正在使用 AngularFireDatabase 来获取我的数据库的一部分,就像这样 db.object('/accounts/'+this.cid);
其中 this.cid
是一个可以更改的 BehaviorSubject
。我是不是用错了方法?
cid: BehaviorSubject<string>;
account: FirebaseObjectObservable<any>;
constructor(private db: AngularFireDatabase) {
this.cid = new BehaviorSubject<string>('fs2ejD4ds');
this.account = db.object('/accounts/'+this.cid);
基本上每当我 运行 this.cid.next('fhEj2jd')
我希望它改变我们试图在 Firebase 中引用的对象。