Credit to devdocs.io

angular 2.0_typescript

angular

NgIf

Stable Directive

Class Overview

class NgIf {
  constructor(_viewContainer: ViewContainerRef, _template: TemplateRef<Object>)
  
  
  ngIf 
}

Selectors

[ngIf]

Class Description

Removes or recreates a portion of the DOM tree based on an {expression}.

If the expression assigned to ngIf evaluates to a false value then the element is removed from the DOM, otherwise a clone of the element is reinserted into the DOM.

Example (live demo):

<div *ngIf="errorCount > 0" class="error">
  <!-- Error message displayed when the errorCount property on the current context is greater
than 0. -->
  {{errorCount}} errors detected
</div>

Syntax

  • <div *ngIf="condition">...</div>
  • <div template="ngIf condition">...</div>
  • <template [ngIf]="condition"><div>...</div></template>

Constructor

constructor(_viewContainer: ViewContainerRef, _template: TemplateRef<Object>)

Class Details

ngIf

exported from @angular/common/index, defined in @angular/common/src/directives/ng_if.ts

© 2010–2016 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/docs/ts/latest/api/common/index/NgIf-directive.html