From 876d14f973624a932a7b14ceacc176eee183a212 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Tue, 9 Nov 2021 15:39:43 +0300 Subject: [PATCH] fix an error in replaceable-template.directive --- .../lib/directives/replaceable-template.directive.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/directives/replaceable-template.directive.ts b/npm/ng-packs/packages/core/src/lib/directives/replaceable-template.directive.ts index 329cf4f4ed..5a96ada9a9 100644 --- a/npm/ng-packs/packages/core/src/lib/directives/replaceable-template.directive.ts +++ b/npm/ng-packs/packages/core/src/lib/directives/replaceable-template.directive.ts @@ -24,7 +24,7 @@ import { SubscriptionService } from '../services/subscription.service'; }) export class ReplaceableTemplateDirective implements OnInit, OnChanges { @Input('abpReplaceableTemplate') - data!: ReplaceableComponents.ReplaceableTemplateDirectiveInput; + data: ReplaceableComponents.ReplaceableTemplateDirectiveInput; providedData = { inputs: {}, @@ -122,7 +122,7 @@ export class ReplaceableTemplateDirective implements OnInit, OnChanges { if (!this.defaultComponentSubscriptions[key]) { this.defaultComponentSubscriptions[key] = this.defaultComponentRef[key].subscribe( (value: any) => { - this.data.outputs[key](value); + this.data.outputs?.[key](value); }, ); } @@ -132,7 +132,7 @@ export class ReplaceableTemplateDirective implements OnInit, OnChanges { } setProvidedData() { - this.providedData = { ...this.data, inputs: {} }; + this.providedData = { ...this.data, inputs: {}, outputs: {} }; if (!this.data.inputs) return; Object.defineProperties(this.providedData.inputs, { @@ -142,8 +142,8 @@ export class ReplaceableTemplateDirective implements OnInit, OnChanges { [key]: { enumerable: true, configurable: true, - get: () => this.data.inputs[key].value, - ...(this.data.inputs[key].twoWay && { + get: () => this.data.inputs[key]?.value, + ...(this.data.inputs[key]?.twoWay && { set: (newValue: any) => { this.data.inputs[key].value = newValue; this.data.outputs[`${key}Change`](newValue);