1.0.3 • Published 5 years ago

ng-bootstrap-nested-select v1.0.3

Weekly downloads
16
License
MIT
Repository
github
Last release
5 years ago

ng-bootstrap-nested-select

Installation

To install this library, run:

$ npm install ng-bootstrap-nested-select --save

Dependencies to install

$ npm install bootstrap --save

Then you'll need to add the bootstrap.min.css file if you haven't already to you angular config file

"styles": [
  "node_modules/bootstrap/dist/css/bootstrap.min.css",
  "src/styles.css"
],

Consuming your library

Once you have published your library to npm, you can import your library in any Angular application by running:

$ npm install ng-bootstrap-nested-select

and then from your Angular AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import your library
import { NgBootstrapNestedSelectModule } from 'ng-bootstrap-nested-select';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgBootstrapNestedSelectModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Inputs

OptionTypeDescription
optionsArrayAn array of object where each must have a "name" and "options" fields
settingsNgBootstrapNestedSelectSettingsAn object of settings to control the select box
defaultObjectThe default object to show, from the "options" list
actionsNgBootstrapNestedSelectActionsAn array of action (links or buttons) that will be displayed within the select box
disabledBooleanDisable the select box

Outputs

OptionTypeDescription
selectedobjectPasses back selected object
actionSelectobjectPasses back the action object when one is selected

NgBootstrapNestedSelectActions actions Input

OptionTypeDescription
idNumberUnique ID for this action
labelStringLabel that is displayed to the user

NgBootstrapNestedSelectSettings settings Input

OptionTypeDescriptionDefault
fieldStringThe name of the field that you want to iterate over, which contains the array of options'options'
topBooleanDisplay select options above input fieldfalse
scrollBooleanUse min-height and overflow-y scroll css to limit height of select boxtrue
selectAllBooleanAllows user to select multi optionsfalse
collapsedBooleanCollapse all child options and only display top most parentfalse
labelStringName of the field in the option object to display as label in drop down.'name'
clearString or BooleanSet text of clear button. Setting to false will hide clear button.'Clear'
strictBooleanDisabled search. Only list options.false
filter{fields: ...array of fields as strings}Fields in each option to search for when filtering.
actionsStringThe style of the action options. 'link' = plain text, 'buttons' = bootstrap button'link'
requiredBooleanField is required. Adds "required" class.false
indexedOptionsBoolean
numberInputBoolean type is "number"false
matchRatingFloatUsing the "string-similarity" package, a rating number between 0-1. See https://www.npmjs.com/package/string-similarity0.4
emptyTextStringText to display when no options are available
popoverTitleString or BooleanWhen disabled, select box will have a popover of option selected. This is title to that popover. false = hide popover
<!--
myOptions = [
    { 
        name: 'Parent Item', 
        options: [
            { 
                name: 'Child Item', 
                options [
                    ...
                ]
            }
        ]
    }
];
-->
<nested-select 
    [options]="myOptions" 
    [default]="myOptions[0].options[0]" 
    [settings]="{collapsed: true, strict: false}" 
    [actions]="{id: 1, label: 'Add Option'}"
    (selected)="triggerSelected($event)" 
    (actionSelected)="triggerAction($event)">

</nested-select>

License

MIT © Scot Schroeder

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.1

5 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago