source: trip-planner-front/node_modules/@angular/common/esm2015/src/directives/ng_if.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 23.8 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Directive, Input, TemplateRef, ViewContainerRef, ɵstringify as stringify } from '@angular/core';
9/**
10 * A structural directive that conditionally includes a template based on the value of
11 * an expression coerced to Boolean.
12 * When the expression evaluates to true, Angular renders the template
13 * provided in a `then` clause, and when false or null,
14 * Angular renders the template provided in an optional `else` clause. The default
15 * template for the `else` clause is blank.
16 *
17 * A [shorthand form](guide/structural-directives#asterisk) of the directive,
18 * `*ngIf="condition"`, is generally used, provided
19 * as an attribute of the anchor element for the inserted template.
20 * Angular expands this into a more explicit version, in which the anchor element
21 * is contained in an `<ng-template>` element.
22 *
23 * Simple form with shorthand syntax:
24 *
25 * ```
26 * <div *ngIf="condition">Content to render when condition is true.</div>
27 * ```
28 *
29 * Simple form with expanded syntax:
30 *
31 * ```
32 * <ng-template [ngIf]="condition"><div>Content to render when condition is
33 * true.</div></ng-template>
34 * ```
35 *
36 * Form with an "else" block:
37 *
38 * ```
39 * <div *ngIf="condition; else elseBlock">Content to render when condition is true.</div>
40 * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
41 * ```
42 *
43 * Shorthand form with "then" and "else" blocks:
44 *
45 * ```
46 * <div *ngIf="condition; then thenBlock else elseBlock"></div>
47 * <ng-template #thenBlock>Content to render when condition is true.</ng-template>
48 * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
49 * ```
50 *
51 * Form with storing the value locally:
52 *
53 * ```
54 * <div *ngIf="condition as value; else elseBlock">{{value}}</div>
55 * <ng-template #elseBlock>Content to render when value is null.</ng-template>
56 * ```
57 *
58 * @usageNotes
59 *
60 * The `*ngIf` directive is most commonly used to conditionally show an inline template,
61 * as seen in the following example.
62 * The default `else` template is blank.
63 *
64 * {@example common/ngIf/ts/module.ts region='NgIfSimple'}
65 *
66 * ### Showing an alternative template using `else`
67 *
68 * To display a template when `expression` evaluates to false, use an `else` template
69 * binding as shown in the following example.
70 * The `else` binding points to an `<ng-template>` element labeled `#elseBlock`.
71 * The template can be defined anywhere in the component view, but is typically placed right after
72 * `ngIf` for readability.
73 *
74 * {@example common/ngIf/ts/module.ts region='NgIfElse'}
75 *
76 * ### Using an external `then` template
77 *
78 * In the previous example, the then-clause template is specified inline, as the content of the
79 * tag that contains the `ngIf` directive. You can also specify a template that is defined
80 * externally, by referencing a labeled `<ng-template>` element. When you do this, you can
81 * change which template to use at runtime, as shown in the following example.
82 *
83 * {@example common/ngIf/ts/module.ts region='NgIfThenElse'}
84 *
85 * ### Storing a conditional result in a variable
86 *
87 * You might want to show a set of properties from the same object. If you are waiting
88 * for asynchronous data, the object can be undefined.
89 * In this case, you can use `ngIf` and store the result of the condition in a local
90 * variable as shown in the following example.
91 *
92 * {@example common/ngIf/ts/module.ts region='NgIfAs'}
93 *
94 * This code uses only one `AsyncPipe`, so only one subscription is created.
95 * The conditional statement stores the result of `userStream|async` in the local variable `user`.
96 * You can then bind the local `user` repeatedly.
97 *
98 * The conditional displays the data only if `userStream` returns a value,
99 * so you don't need to use the
100 * safe-navigation-operator (`?.`)
101 * to guard against null values when accessing properties.
102 * You can display an alternative template while waiting for the data.
103 *
104 * ### Shorthand syntax
105 *
106 * The shorthand syntax `*ngIf` expands into two separate template specifications
107 * for the "then" and "else" clauses. For example, consider the following shorthand statement,
108 * that is meant to show a loading page while waiting for data to be loaded.
109 *
110 * ```
111 * <div class="hero-list" *ngIf="heroes else loading">
112 * ...
113 * </div>
114 *
115 * <ng-template #loading>
116 * <div>Loading...</div>
117 * </ng-template>
118 * ```
119 *
120 * You can see that the "else" clause references the `<ng-template>`
121 * with the `#loading` label, and the template for the "then" clause
122 * is provided as the content of the anchor element.
123 *
124 * However, when Angular expands the shorthand syntax, it creates
125 * another `<ng-template>` tag, with `ngIf` and `ngIfElse` directives.
126 * The anchor element containing the template for the "then" clause becomes
127 * the content of this unlabeled `<ng-template>` tag.
128 *
129 * ```
130 * <ng-template [ngIf]="heroes" [ngIfElse]="loading">
131 * <div class="hero-list">
132 * ...
133 * </div>
134 * </ng-template>
135 *
136 * <ng-template #loading>
137 * <div>Loading...</div>
138 * </ng-template>
139 * ```
140 *
141 * The presence of the implicit template object has implications for the nesting of
142 * structural directives. For more on this subject, see
143 * [Structural Directives](https://angular.io/guide/built-in-directives#one-per-element).
144 *
145 * @ngModule CommonModule
146 * @publicApi
147 */
148export class NgIf {
149 constructor(_viewContainer, templateRef) {
150 this._viewContainer = _viewContainer;
151 this._context = new NgIfContext();
152 this._thenTemplateRef = null;
153 this._elseTemplateRef = null;
154 this._thenViewRef = null;
155 this._elseViewRef = null;
156 this._thenTemplateRef = templateRef;
157 }
158 /**
159 * The Boolean expression to evaluate as the condition for showing a template.
160 */
161 set ngIf(condition) {
162 this._context.$implicit = this._context.ngIf = condition;
163 this._updateView();
164 }
165 /**
166 * A template to show if the condition expression evaluates to true.
167 */
168 set ngIfThen(templateRef) {
169 assertTemplate('ngIfThen', templateRef);
170 this._thenTemplateRef = templateRef;
171 this._thenViewRef = null; // clear previous view if any.
172 this._updateView();
173 }
174 /**
175 * A template to show if the condition expression evaluates to false.
176 */
177 set ngIfElse(templateRef) {
178 assertTemplate('ngIfElse', templateRef);
179 this._elseTemplateRef = templateRef;
180 this._elseViewRef = null; // clear previous view if any.
181 this._updateView();
182 }
183 _updateView() {
184 if (this._context.$implicit) {
185 if (!this._thenViewRef) {
186 this._viewContainer.clear();
187 this._elseViewRef = null;
188 if (this._thenTemplateRef) {
189 this._thenViewRef =
190 this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
191 }
192 }
193 }
194 else {
195 if (!this._elseViewRef) {
196 this._viewContainer.clear();
197 this._thenViewRef = null;
198 if (this._elseTemplateRef) {
199 this._elseViewRef =
200 this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
201 }
202 }
203 }
204 }
205 /**
206 * Asserts the correct type of the context for the template that `NgIf` will render.
207 *
208 * The presence of this method is a signal to the Ivy template type-check compiler that the
209 * `NgIf` structural directive renders its template with a specific context type.
210 */
211 static ngTemplateContextGuard(dir, ctx) {
212 return true;
213 }
214}
215NgIf.decorators = [
216 { type: Directive, args: [{ selector: '[ngIf]' },] }
217];
218NgIf.ctorParameters = () => [
219 { type: ViewContainerRef },
220 { type: TemplateRef }
221];
222NgIf.propDecorators = {
223 ngIf: [{ type: Input }],
224 ngIfThen: [{ type: Input }],
225 ngIfElse: [{ type: Input }]
226};
227/**
228 * @publicApi
229 */
230export class NgIfContext {
231 constructor() {
232 this.$implicit = null;
233 this.ngIf = null;
234 }
235}
236function assertTemplate(property, templateRef) {
237 const isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView);
238 if (!isTemplateRefOrNull) {
239 throw new Error(`${property} must be a TemplateRef, but received '${stringify(templateRef)}'.`);
240 }
241}
242//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmdfaWYuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21tb24vc3JjL2RpcmVjdGl2ZXMvbmdfaWYudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLFNBQVMsRUFBbUIsS0FBSyxFQUFFLFdBQVcsRUFBRSxnQkFBZ0IsRUFBRSxVQUFVLElBQUksU0FBUyxFQUFDLE1BQU0sZUFBZSxDQUFDO0FBR3hIOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Oz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