Angular-Select2
This project was generated with Angular CLI version 1.0.1.
Instructions
This project is built for showing how to use angular-select2-component.
Angular-Select2-Component
Source code in: https://github.com/godbasin/angular4-select2/tree/npm-publish-code.
Related Versions
Angular-Select2-Component is baseed on these plugins and libs(version):
How to use
Install
// npm install
npm install angular-select2-component --save
// if you have not installed jquery
npm install jquery --save
Use as component
- Import component.
// import NgModule
import {NgModule} from '@angular/core';
// import Select2Component
import {Select2Component} from 'angular-select2-component';
@NgModule({
// ...
// declare components
declarations: [Select2Component]
})
export class YourModule {
}
- Template.
<select2 [options]="options" [(ngModel)]="optionSelected" (onSelect)="onSelect($event)"></select2>
Options
options
:option[]
- select options for select2
option
:{id: value, text: key}
orstring
ngModel
: option value that is selected(id
orstring
)onSelect
- callback when option selected
- parmas:
option
({id: value, text: key}
orstring
)