ng_if.js
2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
/**
* Removes or recreates a portion of the DOM tree based on an {expression}.
*
* If the expression assigned to `ngIf` evaluates to a falsy value then the element
* is removed from the DOM, otherwise a clone of the element is reinserted into the DOM.
*
* ### Example ([live demo](http://plnkr.co/edit/fe0kgemFBtmQOY31b4tw?p=preview)):
*
* ```
* <div *ngIf="errorCount > 0" class="error">
* <!-- Error message displayed when the errorCount property in 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>`
*
* \@stable
*/
export var NgIf = (function () {
/**
* @param {?} _viewContainer
* @param {?} _template
*/
function NgIf(_viewContainer, _template) {
this._viewContainer = _viewContainer;
this._template = _template;
this._hasView = false;
}
Object.defineProperty(NgIf.prototype, "ngIf", {
/**
* @param {?} condition
* @return {?}
*/
set: function (condition) {
if (condition && !this._hasView) {
this._hasView = true;
this._viewContainer.createEmbeddedView(this._template);
}
else if (!condition && this._hasView) {
this._hasView = false;
this._viewContainer.clear();
}
},
enumerable: true,
configurable: true
});
NgIf.decorators = [
{ type: Directive, args: [{ selector: '[ngIf]' },] },
];
/** @nocollapse */
NgIf.ctorParameters = function () { return [
{ type: ViewContainerRef, },
{ type: TemplateRef, },
]; };
NgIf.propDecorators = {
'ngIf': [{ type: Input },],
};
return NgIf;
}());
function NgIf_tsickle_Closure_declarations() {
/** @type {?} */
NgIf.decorators;
/**
* @nocollapse
* @type {?}
*/
NgIf.ctorParameters;
/** @type {?} */
NgIf.propDecorators;
/** @type {?} */
NgIf.prototype._hasView;
/** @type {?} */
NgIf.prototype._viewContainer;
/** @type {?} */
NgIf.prototype._template;
}
//# sourceMappingURL=ng_if.js.map