onFocus event not working in Primng Autocomplete
Hi , I am trying to use onFocus() event of Autocomplete , but the event is not getting fired even if the aucomplete box gets focus.
Also I am trying to make the make the input box look red when the list is empty according to the typed characters, it is working fine , but when i am clearing the box with backspace then the color of the box is red even if the input box is empty.
I think the best way to get it looked at/resolved is to follow the issue logging guidelines and include plunkr showing your problem.
I tried it locally and everything seems working fine try it like this.
<p-autoComplete [(ngModel)]="country" [suggestions]="filteredCountriesSingle" (completeMethod)="filterCountrySingle($event)" field="name" [size]="30"
placeholder="Countries" [minLength]="1" (onFocus)="test()"></p-autoComplete>
For me it does not work either. I'm using it with reactive form.
<p-autoComplete
[formControl]="searchControl"
[suggestions]="searchResults"
(completeMethod)="search($event)"
(onFocus)="focus()"
></p-autoComplete>
Update: with PrimeNG version 2.0.1 it was not working but I tried to update to 2.0.2 and it works like a charm now.
Glad to hear that.
working perfectly on version ˆ2.0.4.
I have same problem version 4.X but also not working(angular4.x)
<div class="col-md-6 form-group">
<label class="control-label">* Business type</label>
<p-autoComplete #orgtype="ngModel" name="orgtype" [suggestions]="organization_type_list" [(ngModel)]="selected_organization_type"
(completeMethod)="searchOrganizationType($event)" (focus)="totla()" field="name" placeholder="Organization type" [size]="50" [minLength]="1" required>
</p-autoComplete>
<div *ngIf="orgtype.invalid && (orgtype.dirty || orgtype.touched)" class="text-danger">
<div *ngIf="orgtype.errors.required"> Business type is required.</div>
</div>
</div>
OnFocus() event is not working on Primeng Listbox.
<p-listbox [options]="rentalLocationsName" [(ngModel)]="selectedLocation" (onFocus)="onDropdownFocus()" (onBlur)="onBlurMouse()" [filter]="true" [style]="{ width: '15rem' }" [listStyle]="{'max-height': '220px'}">
onDropdownFocus() { console.log('Dropdown focused!'); }