Browse Source

fix an error in replaceable-template.directive

pull/10581/head
mehmet-erim 5 years ago
parent
commit
876d14f973
  1. 10
      npm/ng-packs/packages/core/src/lib/directives/replaceable-template.directive.ts

10
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 { export class ReplaceableTemplateDirective implements OnInit, OnChanges {
@Input('abpReplaceableTemplate') @Input('abpReplaceableTemplate')
data!: ReplaceableComponents.ReplaceableTemplateDirectiveInput<any, any>; data: ReplaceableComponents.ReplaceableTemplateDirectiveInput<any, any>;
providedData = { providedData = {
inputs: {}, inputs: {},
@ -122,7 +122,7 @@ export class ReplaceableTemplateDirective implements OnInit, OnChanges {
if (!this.defaultComponentSubscriptions[key]) { if (!this.defaultComponentSubscriptions[key]) {
this.defaultComponentSubscriptions[key] = this.defaultComponentRef[key].subscribe( this.defaultComponentSubscriptions[key] = this.defaultComponentRef[key].subscribe(
(value: any) => { (value: any) => {
this.data.outputs[key](value); this.data.outputs?.[key](value);
}, },
); );
} }
@ -132,7 +132,7 @@ export class ReplaceableTemplateDirective implements OnInit, OnChanges {
} }
setProvidedData() { setProvidedData() {
this.providedData = { ...this.data, inputs: {} }; this.providedData = { ...this.data, inputs: {}, outputs: {} };
if (!this.data.inputs) return; if (!this.data.inputs) return;
Object.defineProperties(this.providedData.inputs, { Object.defineProperties(this.providedData.inputs, {
@ -142,8 +142,8 @@ export class ReplaceableTemplateDirective implements OnInit, OnChanges {
[key]: { [key]: {
enumerable: true, enumerable: true,
configurable: true, configurable: true,
get: () => this.data.inputs[key].value, get: () => this.data.inputs[key]?.value,
...(this.data.inputs[key].twoWay && { ...(this.data.inputs[key]?.twoWay && {
set: (newValue: any) => { set: (newValue: any) => {
this.data.inputs[key].value = newValue; this.data.inputs[key].value = newValue;
this.data.outputs[`${key}Change`](newValue); this.data.outputs[`${key}Change`](newValue);

Loading…
Cancel
Save