如何从代码刷新 ngIf 方法调用

How do I refresh ngIf method call from code

我是我的 angular 5 组件的 HTML 文件 我已将 *ngIf 附加到 td 元素:

<tr *ngFor="let ar of ars">
    <td *ngIf="showCompleteButton(ar)">

我遇到的问题是 showCompleteButton 访问的元素可能尚未从网络加载。当我需要的网络元素加载时,我如何告诉页面重新运行该检查以便按钮开始出现?

我知道如何通过网络调用 .subscribe() 在加载完成后采取行动,我只是不知道如何在那时重新评估 *ngIf 调用。

在订阅中填写的模板中创建成员变量对您有用吗?如 ts:

showCompleteButton = {};

yourApiCall.subscribe(ars => {
 this.ars = ars;
 ars.forEach(ar => {
   this.showCompleteButton[ar] = this.showCompleteButton(ar);
   //do not know what type ar is but you get the idea...
 });

在HTML中:

<td *ngIf="showCompleteButton[ar]">

旁注:从模板调用函数对性能不利,它会在每个循环中被反复调用。