Estoy usando select2 con Angular. Tengo muchos resultados (alrededor de 5k) abrir el cuadro de selección es bastante lento.
este es mi componente
ngAfterViewInit(): void { $('#carrierSelector').select2({ matcher: (params, data) => { const { value } = data.element; let filter:string = String(params.term).toLowerCase();; const { Name, CarrierId, CarrierName } = this.carriers.find((item:ICarrier) => item.index === parseInt(value)); // If there are no search terms, return all of the data if ($.trim(params.term) === '') { return data; } if (Name.toLowerCase().indexOf(filter) > -1 || CarrierId.toLowerCase().indexOf(filter) > -1 || CarrierName.toLowerCase().indexOf(filter) > -1) { let modifiedData = $.extend({}, data, true); return modifiedData; } // Return `null` if the term should not be displayed return null; } }); }Probé muchas formas como ajax, pero no me funciona