|
@@ -91,7 +91,7 @@ export interface Callbacks {
|
|
|
export class DynaformService {
|
|
|
|
|
|
public buildFormGroup: (meta) => FormGroup;
|
|
|
- private callbacks: Callbacks = {};
|
|
|
+ public callbacks: Callbacks = {};
|
|
|
|
|
|
constructor(private fb: FormBuilder) {
|
|
|
this.buildFormGroup = buildFormGroupFunctionFactory(fb);
|
|
@@ -103,14 +103,15 @@ export class DynaformService {
|
|
|
}
|
|
|
|
|
|
register(callbacks: Callbacks, cref: ComponentRef<any>['instance']) {
|
|
|
- // Bind the component instance to the callback, so that 'this' has the context of the component
|
|
|
if (cref) {
|
|
|
+ // Bind the component instance to the callback, so that 'this' has the context of the component
|
|
|
Object.entries(callbacks).forEach(([key, fn]) => this.callbacks[key] = fn.bind(cref));
|
|
|
+ } else {
|
|
|
+ this.callbacks = callbacks;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
call(fnId: string) {
|
|
|
- console.log('Dynaform Service', fnId);
|
|
|
// Handle callback events
|
|
|
try {
|
|
|
this.callbacks[fnId]();
|