Angular 7中的CombineLatest未执行

时间:2019-04-04 10:27:16

标签: angular typescript angular7

combineLatest(this.route.params, this.campaignService.count()).pipe(flatMap(result => {

  console.log('combinelatest');
  const params = result[0];

  this.count = result[1];

  if (params['page']) {
    this.page = params['page'];
  }
  this.offset = (this.page - 1) * this.limit;

  return this.campaignService.list(this.offset);
})).subscribe(json => {
  this.campaignList = json;
}, error => {
  let message;
  if (error.status === 401) {
    message = 'Unauthorized';
  } else if (error.status === 500) {
    message = 'Internal server error';
  } else if (error.status === 400) {
    message = 'Bad request';
  }

  const modalRef = this.modalService.open(GeneralModalComponent);
  modalRef.componentInstance.modalTitle = 'Error';
  modalRef.componentInstance.modalMessage = message;
});

所以我正在使用Angular 7的CombineLatest来使用flatMap链接来调用API,但是似乎代码没有在执行。您认为我在此代码片段中错过了什么?我正在Angular 6中对其进行修改。以前的Observable.combineLatest,flatMap,然后进行了订阅。

0 个答案:

没有答案