html - Ne znam kako postaviti opcije u ngx-select-dropdown Angular 8


Želio bih dobiti padajući popis u svojoj komponenti.

U mom HTML-u imam

<ngx-select-dropdown [options]="list"></ngx-select-dropdown>

I u TypeScript datoteci:

this.list = [
      {id:1,display:'job'},
      {id:2,display:'task'},
            ];
  }

Kako postaviti svoj popis opcija u .ts? Je li ispravno koristiti "options"?

Odgovor #1

Da. U službenom dokumentu piše:

options: Array - Array of string/objects that are to be the dropdown options.

Više možete pročitati ovdje: https://github.com/manishjanky/ngx-select-dropdown#readme

Odgovor #2

u ngOnInit

this.selectConfig = {
            //limitTo: this.cities.length,
            limitTo: 1000,
            displayKey: 'name',
            search: true, // true/false for the search functionlity defaults to false
            // tslint:disable-next-line:max-line-length
            height: 'auto', // height of the list so that if there are more no of items it can show a scroll defaults to auto. With auto height scroll will never appear
            placeholder: 'Seleccione Ciudad', // text to be displayed when no item is selected defaults to Select,
            noResultsFound: 'No se encontraron resultados!', // text to be displayed when no items are found while searching
            searchPlaceholder: 'Buscar', // label thats displayed in search input,
            // tslint:disable-next-line:max-line-length
            searchOnKey: 'name', // key on which search should be performed this will be selective search. if undefined this will be extensive search on all keys
            clearOnSelection: false, // clears search criteria when an option is selected if set to true, default is false
        };