【发布时间】:2019-10-04 20:21:45
【问题描述】:
我的问题和this one非常相似。
在foo.component.html:
<ng-container *ngFor="let item of items">
<ng-container *ngIf="(fooFunc(item.property) | async) as element">
{{ element | json }}
</ng-container>
</ng-container>
在foo.component.ts:
fooFunc(foo: any) {
return this.fooService.fooServiceFunc(foo).pipe(
take(1),
shareReplay(1)
);
}
fooService 中的fooServiceFunc 一次只会返回一个Observable。
我的问题是,现在我的应用程序触发了无限请求(在整个 items 数组被迭代之后,它会从头开始,一遍又一遍地再次触发请求),这似乎是 @987654331 的副作用@管道在this answer中宣布。但我仍然不知道如何解决这个问题?
【问题讨论】:
标签: javascript angular typescript asynchronous pipe