I have a directive for validation [appInvalidField], it's like a custom tooltip. Since I need to use it inside dialogs and show it above everything else, I append that to body and position near a field it has to be shown next to.
But there is a problem with scrolling. I need to listen to a scroll event on form and change a tooltip position. How can I do that without changing my html? Just inside the directive file. Here is my HTML(an example of using it inside a form):
<form #ngForm="ngForm" [formGroup]="form" (ngSubmit)="onSave()">
<div class="form--edit">
<div class="form__group p-grid">
<label class="p-col-12 form__label">{{'substance.IUPACName-title' | translate}}</label>
<div appInvalidField="names">
<span *appInvalidFieldType="'required'" [translate]="'substance.IUPACName-field-required'"></span>
<span *appInvalidFieldType="'maxlength'"
[translate]="'substance.IUPACName-field-maxlength'"></span>
</div>
<input class="p-col" pInputText [maxLength]="formService.maxLength" appAutofocus formControlName="names" />
</div>
</div>
</form>