我需要获取kendo-maskedtextbox容器元素ref,以正确地将悬停组件锚定到它。但是,当我使用#cprNrAnchor时,我得到组件实例,有没有办法做到这一点,或者我很幸运看到它在第三方组件中是私有的。
<div class="form-group" fxLayout="row" fxLayoutAlign="start center">
<label fxFlex="150px" class="form-control-label">CPR-nr.</label>
<kendo-maskedtextbox #cprNrAnchor mask="000000-0000" class="form-control" fxFlexOffset="20px" formControlName="cprNr"></kendo-maskedtextbox>
<control-messages [anchor]="cprNrAnchor" [control]="personinfoForm.get('cprNr')"></control-messages>
</div>
答案 0 :(得分:0)
您可以使用MaskedTextBox的输入字段作为锚点,例如:
<form #templateForm="ngForm" novalidate>
<p>Enter valid postcode (A9 9AA)</p>
<kendo-maskedtextbox #mtb
name="value1"
[(ngModel)]="value"
[mask]="mask"
[maskValidation]="maskValidation"
></kendo-maskedtextbox>
<button [disabled]="!templateForm.valid" type="submit" class="k-button">Submit</button>
</form>
<kendo-popup
[popupClass]="'content popup'"
[anchor]="mtb.input"
(anchorViewportLeave)="show = false"
*ngIf="!templateForm.valid">
Invalid input content
</kendo-popup>
...或者通过AfterViewInit处理程序中的ViewChild引用获取对容器的引用,并将其设置为弹出窗口的锚点,例如:
<kendo-maskedtextbox #mtb...
@ViewChild('mtb') private mtb;
//...
ngAfterViewInit() {
this.mtbWrapper = this.mtb.input.nativeElement.parentElement;
}
<kendo-popup
[popupClass]="'content popup'"
[anchor]="mtbWrapper"