Answers for "ngif"

11

ngif else

<div *ngIf="isLoggedIn; else loggedOut">
  Welcome back, friend.
</div>

<ng-template #loggedOut>
  Please friend, login.
</ng-template>
Posted by: Guest on April-01-2020
13

ng if else

<div *ngIf="condition; else elseBlock">Content to render when condition is true.</div>
<ng-template #elseBlock>Content to render when condition is false.</ng-template>
Posted by: Guest on March-03-2020
0

ngif

<div *ngIf="condition">Content to render when condition is true.</div>
Posted by: Guest on February-09-2021
4

ngIf else

content_copy
      
      <div *ngIf="condition; then thenBlock else elseBlock"></div>
<ng-template #thenBlock>Content to render when condition is true.</ng-template>
<ng-template #elseBlock>Content to render when condition is false.</ng-template>
Posted by: Guest on April-02-2020
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
Posted by: Guest on June-20-2020
0

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;
}
Posted by: Guest on September-22-2020

Browse Popular Code Answers by Language