UNPKG

fabric8-planner

Version:
40 lines (39 loc) 1.56 kB
/** * This is a directive to store data in a local variable * I developped it from angular's ngIf directive. * https://github.com/angular/angular/blob/6.1.1/packages/common/src/directives/ng_if.ts * * ## Storing result in a variable * * A common pattern is that we need to show a set of properties from the same object. If the * object is undefined, then we have to use the safe-traversal-operator `?.` to guard against * dereferencing a `null` value. This is especially the case when waiting on async data such as * when using the `async` pipe as shown in following example: * * ``` * Hello {{ (userStream|async)?.last }}, {{ (userStream|async)?.first }}! * ``` * There are several inefficiencies in the above example: * - We create multiple subscriptions on `userStream`. One for each `async` pipe, or two in the * example above. * - We have to use the safe-traversal-operator `?.` to access properties, which is cumbersome. * - We have to place the `async` pipe in parenthesis. * * A better way to do this is to use `ngIf` and store the result of the condition in a local */ import { TemplateRef, ViewContainerRef } from '@angular/core'; export declare class NgLetDirective { private _viewContainer; private _context; private _thenTemplateRef; private _thenViewRef; constructor(_viewContainer: ViewContainerRef, templateRef: TemplateRef<NgLetContext>); ngLet: any; private _updateView; } export declare class NgLetContext { $implicit: any; ngLet: any; } export declare class NgLetModule { }