npm.io
1.1.0 • Published 5 years ago

@antin502/ng-multiselect

Licence
ISC
Version
1.1.0
Deps
1
Size
182 kB
Vulns
0
Weekly
0

Angular 9 Ng MultiSelect

Installation

ng-multiselect is available via npm

Using npm:

$ npm install @antin502/ng-multiselect --save
  • Import NgMultiSelect to your AppModule

import { AppComponent } from './app.component';
import {NgMultiselectModule} from '@antin502/ng-multiselect';

@NgModule({
    imports: [
        ....,
        NgMultiselectModule
    ],
    declarations: [
        AppComponent
    ],
    bootstrap: [AppComponent]
})
export class AppModule {}
  • Use it in your template
      <ng-multiselect [dataList]="list"
                      [compareWith]="compareWith"
                      [(selectedValues)]="selected"
                      [options]="{hide: {selectedItems: false, search: true, selectionAll: true}}"
                      [formatter]="formatter"
      select-all-text="" unselect-all-text="">
      </ng-multiselect>
      ....
      list = [];
      selected = [{id: 1}];
      title = 'ng-multiselect';
    
      formatter = (i) => i.text;
      compareWith = (a) => a.id;
    
      ngOnInit(): void {
        for (let i = 0; i < 100; i++) {
          this.list.push({id: i, text: `id=${i}`});
        }
      }
    
    
      log(e) {
        console.log(e);
      }
      ....

Demo

Creator

Vladimir Antin

Keywords