我创建了一个表格,用于加载产品和该产品的相应图像。
但是,当创建产品但没有关联的图像时,我会在其上放一个默认图像。
问题是默认图像在我看来+图像空间显示为失败...当我真的只想拥有默认图像时。
有人知道为什么会这样吗?
HTML
namespace MLExtTest2
{
class LoadModel
{
public LoadModel(string modelpath)
{
var model = Keras.Models.Model.LoadModel(modelpath);
MessageBox.Show(model.ToString());
}
}
}
答案 0 :(得分:1)
尝试使用此作为默认图片:
<img src="assets/semimagem.png" class="imgTable img-fluid" alt="">
和semiagem.png
应该在资产文件夹中可用。
<table class = "gfg" *ngFor="let product of products; let a = index;">
<tr>
<td class = "geeks">
<div *ngIf="imagMap.get(product.id) == null">
<img src="assets/semimagem.png" class="imgTable img-fluid" alt="">
</div>
<img [src]="imagMap.get(product.id)" *ngif="imagMap.get(product.id) !== null" class="imgTable img-fluid">
</td>
</tr>
</table>
答案 1 :(得分:1)
无论如何,您都可以显示图像。仅当不存在默认图像时才需要显示它。您可以按以下方式修改代码
<table class = "gfg" *ngFor="let product of products; let a = index;">
<tr>
<td class = "geeks">
<div *ngIf="imagMap.get(product.id) == null; else nonDefault">
<img src="./assets/semimagem.png" class="imgTable img-fluid" alt="">
</div>
<ng-template #nonDefault>
<img [src]="imagMap.get(product.id)" class="imgTable img-fluid">
</ng-template>
</td>
</tr>
</table>
了解ng {否则,Here
答案 2 :(得分:1)
请仔细阅读如何使用ngIf,它是Angular的基本组成部分,代表了模板的基本逻辑。
您可以使用ngContainer代替空的<div>
,并引用ngTemplate作为else条件。
<table class = "gfg" *ngFor="let product of products; let a = index;">
<tr>
<td class = "geeks">
<ng-container *ngIf="imagMap.get(product.id) == null; else productImage">
<img src="./assets/semimagem.png" class="imgTable img-fluid" alt="">
</ng-container>
<ng-template #productImage>
<img [src]="imagMap.get(product.id)" class="imgTable img-fluid">
</ng-template>
</td>
</tr>
</table>
您也可以使用逻辑 OR :
<table class = "gfg" *ngFor="let product of products; let a = index;">
<tr>
<td class = "geeks">
<img [src]="imagMap.get(product.id) || './assets/semimagem.png'" class="imgTable img-fluid">
</td>
</tr>
</table>
答案 3 :(得分:1)
newman run $collection -e $environment -r junit --reporter-junit-export $resultFile
或其他方式
newman run
答案 4 :(得分:0)
使用这种方式
<img [attr.src]="imagMap.get(product.id)?imagMap.get(product.id):defaultImage" />
在您的打字稿defaultImage: any = 'assets/semimagem.png';
此处imagMap.get(product.id)
应该返回值或为空