Select box replacement for Angular2+
- Install it:
npm i angular-select-module --save
- Include it in your angular project:
In NgModule add:
import { SelectModule } from 'angular-select-module';
@NgModule({
imports: [
...
SelectModule,
...
]
});
- Use it in your components:
<angular-select items="items" placeholder="'some-text'"></angular-select>
items
- (Array<any>
) - Array of items from which to select. Should be an array of objects withvalue
andtext
properties.selected
- (?string=''
) - Default value of the select. Should bevalue
of the desired object.placeholder
- (?string=''
) - Placeholder text to display when the element has no focus and selected items.showSearch
- (?boolean=true
) - Whentrue
, it enabled search withitn the select box.showSearchThreshold
- (?number=10
) - The minimum number of options that must be present for search box to be shown.showHtml
- (?boolean=false
) - Whentrue
,text
expected to be an html string and will be rendered as such (via[innerHTML]
property)open
- (?boolean=false
) - Whentrue
, the select list will be open. Useful for controlling the select from parent component.
- valueSelected - it fires after a new option selected; returns string with the value of the selected option.
To customize select box - simply override default styles in css. There is not many of them, it is deliberatly minimalistic by default.
Project is in very early stages. Expect heavy bugs and everything breaking(though it is very simple, so there is not really much to break).
I created this component for my own project, because all existing components are either part of the bigger framework, or depends on jQuery, or do not work with my project because of the conflicting dependencies, or probably I simply did not found them. So there you have it, yet another select component for you).
- implement
multiple
option. - more events (on search, on open, etc.)
- methods to control select box
- key shortcuts
- advanced search
- handle large lists
- more options
- add themes
The MIT License (see the LICENSE file for the full text)