ng-select
ng-select copied to clipboard
Using too much ng-select causes lag
Hi,
It might seem a bit obvious, but maybe there is a workarround to deal with it. My case, in building a big form which uses about 200-300 selects, so I made a component for every question of the form (I'm a bit new to Angular BTW, so any sugestion would be welcome):
import { Component, Input } from '@angular/core';
import {
NG_VALUE_ACCESSOR,
} from '@angular/forms';
import { IOption } from 'ng-select';
@Component({
selector: 'question-select',
template: `
<div class="row form-group">
<div class="col-lg-10 col-md-9 col-sm-8 question-text">
<label>{{ item.questions.spa }}</label>
</div>
<div class="col-lg-2 col-md-3 col-sm-4">
<ng-select [options]="options" [noFilter]="10"></ng-select>
</div>
</div>
`,
styles: [`
.row.form-group {
background-color: inherit;
padding: 4px 0;
margin-bottom: 0;
}
.row.form-group > .question-text {
padding-top: 3px;
}
`],
providers: [
{provide: NG_VALUE_ACCESSOR, useExisting: QuestionSelectComponent, multi: true}
],
})
export class QuestionSelectComponent {
public options:Array<IOption>;
@Input('item') item:any;
ngOnInit() { this.options = Object.keys(this.item['options']).map((k) => { return { value: k, label: this.item['options'][k]['captions']['spa'] }}) }
}
So, every time I need a select:
<question-select [item]="form['my-var']" [(ngModel)]="data['my-var']"></question-select>

But, the problem came when I realized that opening a ng-select takes 2 or 3 seconds to show/hide the dropdown, so I opened the performance monitor of firefox:

There were a bunch of Garbage Collector traces slowing the show event, is this the expected behaviour?.
thanks in advance.
Edit: did a few more tests, 250 ng-selects components not beeing inside a custom component result in the same lag.
Did anyone get the same issue?