i'am trying to load pictureA or pictureB. My first solution is like this:
<img *ngIf="my_picture" src="" width="180" height="80" >
<img *ngIf="default_picture && !my_picture" src="">
But i would like use if-else like on API-Reference:
<div *ngIf="condition; else elseBlock">...</div>
<ng-template #elseBlock>...</ng-template>
So i do it like this:
<div *ngIf="my_picture; else elseBlock">
<img src="" >
</div>
<ng-template #elseBlock>
<img src="" >
</ng-template>
But i get a big exception-stack:
zone.js:388 Unhandled Promise rejection: Template parse errors: Can't bind to 'ngIfElse' since it isn't a known property of 'div'. (" --> <div [ERROR ->]*ngIf="my_picture; else elseBlock"> <img src=""): UserComponent@15:13 Property binding ngIfElse not used by any directive on an embedded template. Make sure that the property name is spelled correctly andall directives are listed in the "@NgModule.declarations". (" -->
[ERROR ->]<div *ngIf="my_picture; else elseBlock"> <img src="" width="180" height="8"): UserComponent@15:8 'ng-template' is not a known element
How can i reliaze simple if-else block?
Aucun commentaire:
Enregistrer un commentaire