【发布时间】:2019-11-05 11:04:11
【问题描述】:
我正在使用 myObject 数组的 observable 来填充我的 html 模板中的输入类型选择。 我希望能够根据条件向我的列表中添加另一个选项。
=> 我想将myItem = Observable <myObject> 添加到我的myList = Observable<myObject[]>
我从 http 方法中检索两个 observables。 我在文档中找不到任何操作员来执行此操作。
我可以通过像这样订阅 myItem 来做到这一点
myList.pipe(
map(x=> myItem.subscribe(y=> x.push(y)))
)
但我更愿意在没有订阅的情况下这样做。
我的模板是这样的
<mat-form-field>
<mat-select [value]="selected$ | async" (selectionChange)="getSelectedValue($event)">
<mat-option *ngFor="let item of myList | async" [value]="item.Id">{{item.Name}} </mat-option>
</mat-select>
</mat-form-field>```
【问题讨论】:
标签: angular typescript rxjs angular7