How to Use ngif

Download angular2 eBook

Introduction

*NgIf: It removes or recreates a part of DOM tree depending on an expression evaluation. It is a structural directive and structural directives alter the layout of the DOM by adding, replacing and removing its elements.

Syntax

  • <div *ngIf="false"> test </div> <!-- evaluates to false -->
  • <div *ngIf="undefined"> test </div> <!-- evaluates to false -->
  • <div *ngIf="null"> test </div> <!-- evaluates to false -->
  • <div *ngIf="0"> test </div> <!-- evaluates to false -->
  • <div *ngIf="NaN"> test </div> <!-- evaluates to false -->
  • <div *ngIf=""> test </div> <!-- evaluates to false -->
  • All other values evaluate to true.

Related Examples

Stats

389 Contributors: 4
Wednesday, August 2, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook