Browse Source

Reapply default inputs on data change

Import Angular's effect and add a reactive effect that reads this.data() and, if data.inputs and defaultComponentRef are present, calls setDefaultComponentInputs(). Ensures default component inputs are reapplied when the directive's input data changes.
pull/24777/head
Fahri Gedik 1 month ago
parent
commit
e24bdcd911
  1. 8
      npm/ng-packs/packages/core/src/lib/directives/replaceable-template.directive.ts

8
npm/ng-packs/packages/core/src/lib/directives/replaceable-template.directive.ts

@ -1,5 +1,6 @@
import {
Directive,
effect,
Injector,
OnChanges,
OnInit,
@ -54,6 +55,13 @@ export class ReplaceableTemplateDirective implements OnInit, OnChanges {
this.setDefaultComponentInputs();
},
};
effect(() => {
const data = this.data();
if (data?.inputs && this.defaultComponentRef) {
this.setDefaultComponentInputs();
}
});
}
ngOnInit() {

Loading…
Cancel
Save