Skip to content

Commit b97397d

Browse files
committed
MOBILE-4842 core: Fix passing outputs to dynamic components
1 parent 9fd77e2 commit b97397d

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/core/components/dynamic-component/dynamic-component.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
Type,
3030
inject,
3131
EventEmitter,
32+
OutputEmitterRef,
3233
} from '@angular/core';
3334
import { AsyncDirective } from '@classes/async-directive';
3435
import { CorePromisedValue } from '@classes/promised-value';
@@ -221,12 +222,22 @@ export class CoreDynamicComponent<ComponentClass> implements OnChanges, DoCheck,
221222

222223
const instance = this.componentRef.instance;
223224
for (const name in this.data) {
224-
// Check instance[name] is an Output.
225-
if (instance[name] instanceof EventEmitter) {
226-
continue;
225+
if (this.isOutput(instance[name]) || (instance[name] === undefined && this.isOutput(this.data[name]))) {
226+
instance[name] = this.data[name];
227+
} else {
228+
this.componentRef.setInput(name, this.data[name]);
227229
}
228-
this.componentRef.setInput(name, this.data[name]);
229230
}
230231
}
231232

233+
/**
234+
* Check if a value is an output.
235+
*
236+
* @param value Value to check.
237+
* @returns Whether the value is an output.
238+
*/
239+
protected isOutput(value: unknown): boolean {
240+
return value instanceof EventEmitter || value instanceof OutputEmitterRef;
241+
}
242+
232243
}

0 commit comments

Comments
 (0)