Harvest-Dev / ng-select2

A select2 for Angular
MIT License
55 stars 32 forks source link

Search trigger not working #47

Closed DavidSegura closed 1 year ago

DavidSegura commented 1 year ago

Good afternoon,

I have tested the library in a new project with angular 14. And the search event does not fire when I perform a search.

image image image image

Thanks for your time

Zefling commented 1 year ago

This parameter is required: customSearchEnabled

<select2 [data]="data"
         customSearchEnabled
         (search)="_search($event)"></select2>
Zefling commented 1 year ago

I change the generator to indicate this.

mcfdez commented 1 year ago

Same problem in Angular 16:

<div class="mt-5">
    <form>
        <div class="form-group row">
            <div class="col-md-4">
                <div style="width: 100%">
                    <div class="input-group">
                        <select2
                            customSearchEnabled
                            [data]="data"
                            (search)="searchTrack($event)"
                            displaySearchStatus="always"
                            placeholder="Select track"
                        ></select2>
                        <div class="input-group-prepend">
                            <button class="btn btn-primary" type="button"><i class="fa fa-plus"></i></button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
export class SessionsAddTracksComponent {
    public data = [
        { value: 1, label: 'hola' },
    ];

    /**
     * On search track
     */
    public searchTrack(event: Select2SearchEvent): void {
        console.log(event);
    }
}

The searchTrack method is never fired. What could be happening?

Zefling commented 1 year ago

Please open a new issue. @mcfdez

For me it works : https://stackblitz.com/edit/stackblitz-starters-csm2lz?file=src%2Fmain.ts