angular if el;se code example
Example 1: ngif
<div *ngIf="condition; else elseBlock">
<button class="xx" *ngIf="flag" (click)="doFunct()">Next</button>
--While (t/f boolean variable called "flag") is true
This button will be visible + click button executes function
Once this "flag" becomes false this button disapears
Example 2: ngif
@Component({
selector: 'ng-if-else',
template: `
<button (click)="show = !show">{{show ? 'hide' : 'show'}}</button>
show = {{show}}
<br>
<div *ngIf="show; else elseBlock">Text to show</div>
<ng-template #elseBlock>Alternate text while primary text is hidden</ng-template>
`
})
export class NgIfElse {
show: boolean = true;
}