【发布时间】:2019-09-27 05:50:21
【问题描述】:
在从服务获取数据后,我试图隐藏一个 div 元素,您可以在下面找到 HTML 代码
<progressbar
*ngIf="isLoadingBootStockData"
[value]="100"
type="default">
</progressbar>
最初我将变量 isLoadingBootStockData 分配给 false 并在我从服务中获取所有数据后分配回 true
所以 typeScript 代码如下所示:
return this.cseStockService
.getBootStockMaterials()
.pipe(
map((materialStock) => {
this.isLoadingBootStockData = false;
const MaterialList = this.cseStockService.createCseStockMaterialModels(
materialStock,
this.model.notification,
this.model.listMaterial,
CSE_STOCK.BOOT_STOCK
);
}).subscribe()
所以在上面的代码第 5 行中,我将从 Service 获取数据并将变量分配给 this.isLoadingBootStockData = false;
以便 html div <progressBar>...</progressBar> 得到隐藏
但是,这里的问题是,变量没有被赋值为 false。由于我在 observable 中使用,这不可能吗?
如果没有,我该怎么办?我想在加载数据后将该变量设为 false。
【问题讨论】:
标签: angular html typescript observable angular7