Causes an element and its contents to be added/removed from the DOM conditionally, based on the value of the supplied boolean template expression.

See the Template Syntax section on ngIf for more details.

Examples

<div *ngIf="currentHero != null">Hello, {{currentHero.firstName}}</div>

<template [ngIf]="currentHero != null"> <hero-detail [hero]="currentHero"></hero-detail> </template>

Annotations
  • Directive(selector: "[ngIf]", inputs: const ["ngIf"])

Constructors

NgIf(ViewContainerRef _viewContainer, TemplateRef _templateRef)

Properties

hashCode → int

Get a hash code for this object.

read-only, inherited
ngIf → bool

Whether the content of the directive should be visible.

write-only
runtimeType → Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator ==(other) → bool

The equality operator.

inherited

Methods

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
toString() → String

Returns a string representation of this object.

inherited