1.0.6 • Published 3 years ago
select-dropdown v1.0.6
Select Dropdown
Select Dropdown is an angular component that allows you to create a dropdown selection by passing in a few parameters.
Installation
npm install select-dropdown
In app.module
import { SelectDropdownModule } from 'select-dropdown';
@NgModule({
declarations: [
AppComponent
],
imports: [
SelectDropdownModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Inputs
// Required parameters
options: Map<any, any> | any[]; // the dropdown options (can be a map or an array)
name: string; // the label for the dropdown
// Optional parameters
default: any; // the default selected option, by default, none is selected
readonly: boolean // default is false
Outputs
onSelect: EventEmitter<any>; // emits the value when an option is selected
Usage
"onSelect" is the event listener. When an option is selected, it will emit the key if its a Map and the value if its an Array.
someFunction(event: any) {
console.log(event); // will log the color
// if its a map, it will log the key, not the value.
}
<select-dropdown [name]="'Colors'" [options]="['Blue', 'Red', 'Green']"
[default]="'Red'" (onSelect)="someFunction($event)"></select-dropdown>
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.