All Projects → Innqube → ng2-iq-select2

Innqube / ng2-iq-select2

Licence: other
Angular 2 native select 2 implementation based on bootstrap 3

Programming Languages

typescript
32286 projects
HTML
75241 projects
CSS
56736 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to ng2-iq-select2

select2-to-tree
Select2-to-Tree extends Select2 to support arbitrary level of nesting...
Stars: ✭ 71 (+173.08%)
Mutual labels:  select2
Select2 Bootstrap Theme
A Select2 v4 Theme for Bootstrap 3
Stars: ✭ 841 (+3134.62%)
Mutual labels:  select2
Select2 Bootstrap4 Theme
A theme for Select2 v4 and Bootstrap 4
Stars: ✭ 97 (+273.08%)
Mutual labels:  select2
Ng Select
Select component for angular
Stars: ✭ 291 (+1019.23%)
Mutual labels:  select2
Select2
Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.
Stars: ✭ 25,184 (+96761.54%)
Mutual labels:  select2
Laravel Nova Select2 Auto Complete
Laravel Nova Select2 Auto-Complete
Stars: ✭ 34 (+30.77%)
Mutual labels:  select2
laravel-admin-select2
𝒂𝒔𝒚𝒏𝒄 𝒔𝒆𝒍𝒆𝒄𝒕/𝒎𝒐𝒓𝒑𝒉𝑺𝒆𝒍𝒆𝒄𝒕 𝒇𝒐𝒓 𝒍𝒂𝒓𝒂𝒗𝒆𝒍 𝒂𝒅𝒎𝒊𝒏
Stars: ✭ 42 (+61.54%)
Mutual labels:  select2
FormBundle
Bunch of FormTypes extending some basic Symfony PHP framework FormTypes. ExtensibleTypes makes it possible to allow extra choices by Symfony ChoiceTypes (ChoiceType, EntityType and DocumentType). This can help to make it work with the Select2 jQuery pluggin.
Stars: ✭ 14 (-46.15%)
Mutual labels:  select2
Angular Select2
select2 in angular(>=2.0-release).
Stars: ✭ 16 (-38.46%)
Mutual labels:  select2
Countrycity
🌎 Geodata API - Get countries, and cities to plug in a select drop-down.
Stars: ✭ 62 (+138.46%)
Mutual labels:  select2
Select2 Bootstrap4 Theme
Select2 v4 theme for Bootstrap4
Stars: ✭ 305 (+1073.08%)
Mutual labels:  select2
Choices
A vanilla JS customisable select box/text input plugin ⚡️
Stars: ✭ 4,505 (+17226.92%)
Mutual labels:  select2
Danyuan Application
初学者 spirng-boot版本
Stars: ✭ 47 (+80.77%)
Mutual labels:  select2
django-select2
This is a Django integration for Select2
Stars: ✭ 73 (+180.77%)
Mutual labels:  select2
React Select2 Wrapper
Wrapper for Select2
Stars: ✭ 163 (+526.92%)
Mutual labels:  select2
laravel-simple-select
Laravel Simple Select inputs component for Blade and Livewire.
Stars: ✭ 59 (+126.92%)
Mutual labels:  select2
Laravel Dusk Select2
Select2.js support for the Laravel Dusk testing
Stars: ✭ 31 (+19.23%)
Mutual labels:  select2
geocoder
Geocoder is a Typescript library which helps you build geo-aware applications by providing a powerful abstraction layer for geocoding manipulations
Stars: ✭ 28 (+7.69%)
Mutual labels:  suggest
Django Easy Select2
Select2 input widget for django selectable fields.
Stars: ✭ 165 (+534.62%)
Mutual labels:  select2
Stf Vue Select
stf vue select - most flexible and customized select
Stars: ✭ 61 (+134.62%)
Mutual labels:  select2

ng2-iq-select2

InnQUbe Build Status codecov Code Climate

Angular 2 native select 2 implementation based on bootstrap 4

  • Easily filter on a remote webservice (can be used with a local list too)
  • Works with ids or complete entities
  • Single or multiple modes
  • Forms integration
  • MIT License
  • Last bootstrap 3 compatible version is 7.0.0

Take a look at the demo page


Usage example:

app.module.ts

import { IqSelect2Module } from 'ng2-iq-select2';

@NgModule({
    declarations: [..],
    imports: [.., IqSelect2Module, ...],
    providers: [..]

html file

<form [formGroup]="form">
    <iq-select2 css="form-control input-sm" 
                formControlName="country" 
                [dataSourceProvider]="listCountries"
                [selectedProvider]="loadFromIds"
                [iqSelect2ItemAdapter]="adapter"></iq-select2>
</form>

html file (custom template)

<form [formGroup]="form">
  <iq-select2 css="form-control input-sm" 
                formControlName="country" 
                [dataSourceProvider]="listCountries"
                [selectedProvider]="loadFromIds"
                [iqSelect2ItemAdapter]="adapter">
    <div *iq-select2-template="let item = $entity; let i = $index">
      <span [style.color]="item.color">[{{item.code}}]</span> {{item.name}}
    </div>
  </iq-select2>
</form>

Exposed internal variable to bind $item, $entity, $id, $index

example typescript file

export class Example {
    form: FormGroup;
    listCountries: (term: string) => Observable<Country[]>;
    loadFromIds: (ids: string[]) => Observable<Country[]>;
    adapter: (entity: Country) => IqSelect2Item;
//
    constructor(private countriesService: CountryService,
                private formBuilder: FormBuilder){
    
    }
//
    ngOnInit() {
        this.listCountries = (term: string) => this.countriesService.listCountries(term);
        this.loadFromIds = (ids: string[]) => this.countriesService.loadCountriesFromIds(ids);
        this.adapter = (country: Country) => {
            return {
                id: country.id,
                text: country.name,
                entity: country
            };
        }
        this.form = this.formBuilder.group({
            country: null
        });
    }
};

IqSelect2Item

interface IqSelect2Item {
    id: string;
    text: string;
    entity?: any; // only needed when referenceMode === 'entity'
}

Messages

export class Messages {
    
     static readonly PARTIAL_COUNT_VAR; // Variable to be replaced by the amount of results being shown
     static readonly TOTAL_COUNT_VAR; // Variable to be replaced by the total count of results
    
    moreResultsAvailableMsg?: string;
    noResultsAvailableMsg?: string;
}

Configuration options (Inputs and Outputs)

@Input() dataSourceProvider: (term: string, selected?: any[]) => Observable<IqSelect2Item[]>: the function to get the data based on user input. Selected ids or entities are provided in case you want to avoid getting those results again (this could be useful when setting the "resultsCount" property).

@Input() selectedProvider: (ids: string[]) => Observable<IqSelect2Item[]>: the function to get previously selected data when referenceMode === 'id'

@Input() iqSelect2ItemAdapter: (entity: T) => IqSelect2Item: the function to adapt any entity to a IqSelect2Item

@Input() referenceMode: 'id' | 'entity'. Allows to specify if you need the whole entity or just the id.

@Input() multiple: 'true' | 'false'. Allows to select multiple options from the list. The form value is returned as an array.

@Input() clientMode: 'true' | 'false'. If set to true only one request will be sent to the data provider and subsequent searching will happen on the client.

@Input() searchDelay: ms until request is effectively triggered

@Input() placeholder: text to show until a search is performed

@Input() disabled: boolean to control the disabled state of the component

@Input() minimumInputLength: the minimum input length at which the component will request data to the provider

@Input() resultsCount: total count of results produced after entering the search term. A message suggesting further filtering will appear if the results count is greather than the result list shown

@Input() messages: Messages: class to provide custom messages to the component

@Input() css: css classes to be applied

@Input() searchIcon: css icon on the right of the input

@Input() deleteIcon: css icon to be used to remove selected option (In single mode)

@Input() badgeColor: badge bootstrap color: 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark'

@Output() onSelect(item: IqSelect2Item): event triggered when an item is selected

@Output() onRemove(item: IqSelect2Item): event triggered when an item is removed


Reference mode examples

// form.value example with referenceMode === 'id':
{
    'item': 1
}

// form.value example with referenceMode === 'entity':
{
    'item':  {
        'id': 1,
        'property1': 'value',
        ...
    }
}

// form.value example with referenceMode === 'id' and multiple === 'true':
{
    'item': [1,2,3]
}

// form.value example with referenceMode === 'entity' and multiple === 'true':
{
    'item': [{
        'id': 1,
        'property1': 'value',
        ...
    },{
        'id': 2,
        'property1': 'value2',
        ...
    },{
        'id': 3,
        'property1': 'value3',
        ...
    }]
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].