0
我創建了一個發射數組的observable。 如果我在模板中使用它,如:{{ ob | async }}
它工作正常。卸載後的角度RxJS空值
但是,如果我這樣做:
<div *ngIf="is">{{ ob | async | json }}</div>
<div *ngIf="!is">{{ ob | async | json }}</div>
我第一次看到正確的JSON,但如果我翻轉is
,我看到null
。
可觀察creation code:
return Rx.Observable.create((observer: Rx.Observer<Array<GeoFireLocation>>) => {
let locations: Array<GeoFireLocation> = [];
geoQuery.on('key_entered', (key, location, distance) => {
locations = this.insertIntoSortedArray({
key, distance,
coordinates: {
latitude: location[0],
longitude: location[1]
}
}, locations);
observer.next(locations);
});
geoQuery.on('key_exited', (key) => {
locations = locations.filter(location => location.key === key);
observer.next(locations);
});
}).finally(() => geoQuery.cancel());
什麼是'is'變量?你如何設定它的價值? –
切換我翻轉'true' /'false'。默認爲'true',它顯示第一行第一行,但如果我翻轉顯示'null',如果我再次翻轉,再次'null' – Amit
你確定在切換is後有任何排放嗎? – martin