From cb7af1b52eaae5dc29ee7c90eccf0266c6bbf00c Mon Sep 17 00:00:00 2001 From: Wouter Willems Date: Tue, 2 Jul 2024 20:59:08 +0200 Subject: [PATCH] update positions --- .../demo/src/app/demo/demo.component.html | 2 +- projects/demo/src/app/demo/demo.component.ts | 4 ++++ .../src/lib/onRender.component.ts | 23 +++++++++++++++---- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/projects/demo/src/app/demo/demo.component.html b/projects/demo/src/app/demo/demo.component.html index 2df4902..420ed97 100644 --- a/projects/demo/src/app/demo/demo.component.html +++ b/projects/demo/src/app/demo/demo.component.html @@ -1,5 +1,5 @@ - +
diff --git a/projects/demo/src/app/demo/demo.component.ts b/projects/demo/src/app/demo/demo.component.ts index 2032e0f..689f49f 100644 --- a/projects/demo/src/app/demo/demo.component.ts +++ b/projects/demo/src/app/demo/demo.component.ts @@ -254,6 +254,10 @@ export class DemoComponent { console.log(this.simpleFormWithFormLevelErrors.get('firstName').errors); }; + onRenderFn = (a) => { + console.log(a); + }; + blurry() { console.log('blurr'); } diff --git a/projects/klippa/ngx-enhancy-forms/src/lib/onRender.component.ts b/projects/klippa/ngx-enhancy-forms/src/lib/onRender.component.ts index bb088ad..0a88459 100644 --- a/projects/klippa/ngx-enhancy-forms/src/lib/onRender.component.ts +++ b/projects/klippa/ngx-enhancy-forms/src/lib/onRender.component.ts @@ -1,14 +1,29 @@ -import {AfterViewInit, Directive, Input} from "@angular/core"; +import { + AfterViewInit, + Component, + ComponentRef, + Directive, ElementRef, + Host, Inject, inject, InjectionToken, + Injector, + Input, + OnInit, + Optional, + Self, + SkipSelf, ViewContainerRef +} from "@angular/core"; import {runNextRenderCycle} from "./util/angular"; - @Directive({ selector: '[onRenderFn]' }) export class OnRenderDirective implements AfterViewInit { - @Input() onRenderFn: () => any; + constructor(@Host() @Self() @Optional() private hostComponent: any) { + } + @Input() onRenderFn: (a: any) => any; ngAfterViewInit(): void { - runNextRenderCycle(() => this.onRenderFn()); + console.log(this.hostComponent); + // const component1 = this.injector.get(); + runNextRenderCycle(() => this.onRenderFn(1)); } }