UNPKG

ng-zorro-antd-yj

Version:

An enterprise-class UI components based on Ant Design and Angular

103 lines 6.89 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core'; export class NzStringTemplateOutletDirective { /** * @param {?} viewContainer * @param {?} defaultTemplate */ constructor(viewContainer, defaultTemplate) { this.viewContainer = viewContainer; this.defaultTemplate = defaultTemplate; this.inputTemplate = null; this.inputViewRef = null; this.defaultViewRef = null; } /** * @param {?} value * @return {?} */ set nzStringTemplateOutlet(value) { if (value instanceof TemplateRef) { this.isTemplate = true; this.inputTemplate = value; } else { this.isTemplate = false; } this.updateView(); } /** * @return {?} */ updateView() { if (!this.isTemplate) { /** use default template when input is string **/ if (!this.defaultViewRef) { this.viewContainer.clear(); this.inputViewRef = null; if (this.defaultTemplate) { this.defaultViewRef = this.viewContainer.createEmbeddedView(this.defaultTemplate); } } } else { /** use input template when input is templateRef **/ if (!this.inputViewRef) { this.viewContainer.clear(); this.defaultViewRef = null; if (this.inputTemplate) { this.inputViewRef = this.viewContainer.createEmbeddedView(this.inputTemplate); } } } } } NzStringTemplateOutletDirective.decorators = [ { type: Directive, args: [{ selector: '[nzStringTemplateOutlet]' },] } ]; /** @nocollapse */ NzStringTemplateOutletDirective.ctorParameters = () => [ { type: ViewContainerRef }, { type: TemplateRef } ]; NzStringTemplateOutletDirective.propDecorators = { nzStringTemplateOutlet: [{ type: Input }] }; if (false) { /** * @type {?} * @private */ NzStringTemplateOutletDirective.prototype.isTemplate; /** * @type {?} * @private */ NzStringTemplateOutletDirective.prototype.inputTemplate; /** * @type {?} * @private */ NzStringTemplateOutletDirective.prototype.inputViewRef; /** * @type {?} * @private */ NzStringTemplateOutletDirective.prototype.defaultViewRef; /** * @type {?} * @private */ NzStringTemplateOutletDirective.prototype.viewContainer; /** * @type {?} * @private */ NzStringTemplateOutletDirective.prototype.defaultTemplate;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