<ion-slides>无法与Firestore异步调用一起使用

时间:2018-08-15 09:23:48

标签: angular ionic-framework observable angularfire2 ionic4

我无法在Ionic v4 beta2中使用angularfire2 / firestore。 一切都已从Firestore正确加载(在检查器中可见),但不允许幻灯片移动。使其起作用的唯一方法是调整浏览器的大小(我想这会触发一些离子幻灯片刷新) 这必须来自以下事实:视图在Firestore返回数据之前已初始化视图,但我认为这是异步管道的关键所在。

类声明

export class HomePage implements OnInit {
  public authUser = {} as UserModel;
  public flightListObs: Observable<FlightModel[]>;
  public flightListCollection: AngularFirestoreCollection<FlightModel>;
  @ViewChild(Slides) slides;

  constructor(
    public auth: AuthService,
    private router: Router,
    private firestore: FirestoreService,
    private afs: AngularFirestore,
  ) { }

ngOnInit函数

async ngOnInit() {
  this.getFlights();
}

getFlights功能

async getFlights() {
  this.auth.user.subscribe(user => {
    this.authUser = user;
    this.flightListCollection = this.afs.collection('flights', ref => ref.where('user', '==', user.uid));
    this.flightListObs = this.flightListCollection.valueChanges();
    this.flightListObs.subscribe(data => {
      console.log('subscription started'); // this works
      this.slides.update(); // this does not do anything
    });
   });
 }

有什么主意,如何让幻灯片通过异步Firestore调用工作? 非常感谢

0 个答案:

没有答案