- Create linked dropdowns
- Create dropdowns with custom styles
- Output change event
- HTML5 elements
- Observable change detection and values
- Required validation state
- Required validation state with custom messages
- Accessibility
- Multiselect
- Mat-Select Support
Library is under active development. Please report any issues or suggestions.
npm install --save ngx-depend-dropdown
yarn add ngx-depend-dropdown
import { NgxDependDropdownModule } from 'ngx-depend-dropdown';
@NgModule({
declarations: [AppComponent],
imports: [NgxDependDropdownModule],
bootstrap: [AppComponent]
})
export class AppModule {}
Define options in your consuming component:
@Component({...})
export class ExampleComponent {
constructor(private dropdownService: DropdownService) {}
config: DropdownConfig = {
nodeClass: 'select-1',
containerClass: 'container',
unavailableType: 'disabled'
}
options: DropdownData = [
{
name: 'select-1',
visibility: () => {
return true;
},
selectedValue: 1,
placeholder: 'placeholder',
values: [],
setValues: () => {
return this.http
.get('https://jsonplaceholder.typicode.com/users')
.pipe(
map((data: any) => {
return data.map((item: any) => {
return {
name: item.name,
id: item.id,
};
});
})
);
},
},
{
name: 'select-2',
visibility: () => {
return !!this.dropdownService.getNodeValue('opt2');
},
selectedValue: 1,
values: [],
dependent: 'select-1',
setValues: () => {
return [{name: 'yasin', id: 1}];
},
},
];
change($event: any) {
console.log($event)
}
}
<ngx-depend-dropdown [options]="options" [config]="config" (onChange)="change($event)"></ngx-depend-dropdown>
Input | Type | Required | Description |
---|---|---|---|
[data] | DropdownData | true | Get all selectboxes data. |
[config] | DropdownConfig | true | Config for selectbox behavior. |
Output | Description |
---|---|
(change) | Fired on selectbox change. |
Output | Description |
---|---|
getNode(nodeName: string) | Gets all node data. |
getNodeValue(nodeName: string) | Gets nodes selected value. |
Contributions are welcome. Feel free to open an issue or create a pull request.
git clone https://github.com/yasincelebi/ngx-depend-dropdown
cd ngx-depend-dropdown
npm install
ng build ngx-depend-dropdown
ng serve example --open
ng test
I have to thank him both for being an inspiration to me and for making a great contribution to the project.