103 lines
1.6 KiB
Plaintext

p.location-badge.
exported from <a href='../directives'>angular2/directives</a>
defined in <a href="https://github.com/angular/angular/tree/2.0.0-alpha.33/modules/angular2/src/directives/ng_if.ts#L3-L48">angular2/src/directives/ng_if.ts (line 3)</a>
:markdown
Removes or recreates a portion of the DOM tree based on an {expression}.
If the expression assigned to `ng-if` 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:
```
<div *ng-if="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 *ng-if="condition">...</div>`
- `<div template="ng-if condition">...</div>`
- `<template [ng-if]="condition"><div>...</div></template>`
.l-main-section
h2 Annotations
.l-sub-section
h3.annotation Directive
pre.prettyprint
code.
@Directive({selector: &#39;[ng-if]&#39;, properties: [&#39;ngIf&#39;]})
.l-main-section
h2 Members
.l-sub-section
h3 constructor
pre.prettyprint
code.
constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef)
:markdown
.l-sub-section
h3 viewContainer
:markdown
.l-sub-section
h3 templateRef
:markdown
.l-sub-section
h3 prevCondition
:markdown
.l-sub-section
h3 ngIf
:markdown