This project was generated with Angular CLI version 1.0.1.
This project is built for showing how to use angular-select2-component.
Source code in: https://github.com/godbasin/angular4-select2/tree/npm-publish-code.
Angular-Select2-Component is baseed on these plugins and libs(version):
// npm install
npm install angular-select2-component --save
// if you have not installed jquery
npm install jquery --save
// import NgModule
import {NgModule} from '@angular/core';
// import Select2Component
import {Select2Component} from 'angular-select2-component';
@NgModule({
// ...
// declare components
declarations: [Select2Component]
})
export class YourModule {
}
<select2 [options]="options" [settings]="{ setting: value }" [(ngModel)]="optionSelected" (onSelect)="onSelect($event)"></select2>
If you have set the include
or exclude
option in your tsconfig.json
, you need to include the node_modules/angular-select2-component/index.ts
file.
// tsconfig.json
{
// ... other options
"include": [
"node_modules/angular-select2-component/index.ts"
]
}
options
: option[]
option
: {id: value, text: key}
or string
ngModel
: option value that is selected
id
or string
while multiple is disableid[]
or string[]
while multiple is enableonSelect
option
({id: value, text: key, selected: ifSelected}
or string
)settings
setting
: { settingOption: value, settingOption: value }