[英]How to detect p-autocomplete ( PrimeNG ) text input change (not value)
<p-autoComplete
id="members"
formControlName="companyId"
field="name"
placeholder="{{ 'SearchByName' | translate }}"
styleClass="width100p"
[suggestions]="companyList"
(keyup)="onKeyup()"
(onSelect)="onSelect()"
(onUnselect)="onUnSelect()"
(completeMethod)="searchCompany($event)"
(onKeyUp)="checkValidity($event)"
(onFocus)="checkValidity($event)"
(onBlur)="checkValidity($event)"
(onShow)="helperService.addScroll('.ui-autocomplete-panel')"
[multiple]="true">
<ng-template let-company pTemplate="item">
<div>{{ company.name }}</div>
</ng-template>
</p-autoComplete>
How to detect p-autocomplete ( PrimeNG ) text input change (not value).如何检测 p-autocomplete ( PrimeNG ) 文本输入更改(不是值)。 I want to detect every change in input field.
我想检测输入字段中的每一个变化。 How to detect it?
如何检测? I can detect it with
(completeMethod)
but it is working not correct in case <if 1 char is inputed and you delete it>, (onKeyUp) but it shows only last key up;我可以用
(completeMethod)
检测到它,但如果 <if 1 char is inputed and you delete it>,它工作不正确>,(onKeyUp) 但它只显示最后一个键; How to take input string value?如何获取输入的字符串值?
You should be able to bind ngModel and ngModelChange but you'll have to apply ngModelOptions = {"standalone": true} in order to get around a binding errorsince you also appear to be using Reactive Forms.您应该能够绑定 ngModel 和 ngModelChange,但您必须应用 ngModelOptions = {"standalone": true} 才能解决绑定错误,因为您似乎也在使用 Reactive Forms。
Alternatively bind to (change) but you'll only get an event per keypress.或者绑定到(更改),但每次按键您只会获得一个事件。
Use $event.target.value
to get the value of your textbox.使用
$event.target.value
获取文本框的值。
(keyup)="checkValidity($event.target.value)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.