Javascript 角形2管道isn';t与可观察到的对象一起工作

Javascript 角形2管道isn';t与可观察到的对象一起工作,javascript,angular,reactive-programming,rxjs,observable,Javascript,Angular,Reactive Programming,Rxjs,Observable,我得到以下错误: EXCEPTION: Cannot find a differ supporting object '[object Object]' in [files | async in Images@1:9] 以下是模板的相关部分: <img *ngFor="#file of files | async" [src]="file.path"> 最后的console.log显示它是一个可观察的: this.imagesData.getData()返回从Angular的H

我得到以下错误:

EXCEPTION: Cannot find a differ supporting object '[object Object]' in [files | async in Images@1:9]
以下是模板的相关部分:

<img *ngFor="#file of files | async" [src]="file.path">
最后的
console.log
显示它是一个可观察的:

this.imagesData.getData()
返回从Angular的
Http
服务可以观察到的常规RxJS,那么为什么异步管道不能使用它呢?也许我使用的
flatMap()
的方式是错误的,它把事情搞砸了

如果我试着同意这样的观察结果:

this.files = this._rawFiles
                .skip((this.currentPage - 1) * imagesPerPage)
                .take(imagesPerPage)
                .subscribe(file => {
                  console.log("file:", file);
                });
它按预期打印对象列表:


尝试使用可观察的
替代:

this.files = this._rawFiles
         .skip((this.currentPage - 1) * imagesPerPage)
         .take(imagesPerPage)
         .map(file => [file])
         .startWith([])
         .scan((acc,value) => acc.concat(value))
这应该不需要手动代码来订阅,并且可以与当前模板完美配合


我在

*ngFor
中做了一些非常类似的事情,只对数组进行迭代,而不是对一系列事件进行迭代,因此您的
Observable
需要返回一个数组,而不是一系列对象。我会使用
scan
操作符来选择一个
Observable
。另请参阅,谢谢。它很管用,虽然不太好看。我已经从服务器接收到一个数组,并且只将其转换为流,以便能够使用RxJS的实用方法(
skip
take
)。如果每次都要这样转换为数组,那么不使用RxJS来进行数组操作就更容易了
this.files = this._rawFiles
         .skip((this.currentPage - 1) * imagesPerPage)
         .take(imagesPerPage)
         .map(file => [file])
         .startWith([])
         .scan((acc,value) => acc.concat(value))