我想尝试加载pictureA或pictureB.
我的第一个解决方案是这样的:
我的第一个解决方案是这样的:
<img *ngIf="my_picture" src="{{my_picture}}" width="180" height="80" > <img *ngIf="default_picture && !my_picture" src="{{default_picture}}">@H_403_4@但我想在API-Reference上使用if-else之类的:
<div *ngIf="condition; else elseBlock">...</div> <ng-template #elseBlock>...</ng-template>@H_403_4@所以我这样做:
<div *ngIf="my_picture; else elseBlock"> <img src="{{my_picture}}" > </div> <ng-template #elseBlock> <img src="{{default_picture}}" > </ng-template>@H_403_4@但我得到一个很大的异常堆栈:
@H_403_4@06003 @H_403_4@all directives are listed in the “@NgModule.declarations”. (”@H_403_4@我怎样才能重新简单的if-else块呢?
–> @H_403_4@06004