I'm using Angular and I want to use *ngIf else
(available since version 4) in this example:
<div *ngIf="isValid">
content here ...
</div>
<div *ngIf="!isValid">
other content here...
</div>
How can I achieve the same behavior with ngIf else
?
Best Answer
Angular 4 and 5:
Using
else
:You can also use
then else
:Or
then
alone:Demo:
Plunker
Details:
<ng-template>
: is Angular’s own implementation of the<template>
tag which is according to MDN: