Select Dropdown is an angular component that allows you to create a dropdown selection by passing in a few parameters.
npm install select-dropdownSelect Dropdown is an angular component that allows you to create a dropdown selection by passing in a few parameters.
``bash`
npm install select-dropdown`
In app.modulets`
import { SelectDropdownModule } from 'select-dropdown';
@NgModule({
declarations: [
AppComponent
],
imports: [
SelectDropdownModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
ts
// Required parameters
options: Map | 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
`ts
onSelect: EventEmitter; // 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.
`ts
someFunction(event: any) {
console.log(event); // will log the color
// if its a map, it will log the key, not the value.
}
``html
[default]="'Red'" (onSelect)="someFunction($event)">
``Please make sure to update tests as appropriate.