diff --git a/src/index.ts b/src/index.ts index 323b5a59f..03494c295 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export { NgSelectComponent, NG_SELECT_DEFAULT_CONFIG } from './ng-select/ng-select.component'; +export { NgSelectComponent, NG_SELECT_DEFAULT_CONFIG, SELECTION_MODEL_FACTORY } from './ng-select/ng-select.component'; export { NgSelectModule } from './ng-select/ng-select.module'; export { NgOption, NgSelectConfig } from './ng-select/ng-select.types'; export { SelectionModel } from './ng-select/selection-model'; diff --git a/src/ng-select/ng-select.module.ts b/src/ng-select/ng-select.module.ts index 63a630d1d..8ad1cc9ff 100644 --- a/src/ng-select/ng-select.module.ts +++ b/src/ng-select/ng-select.module.ts @@ -16,7 +16,7 @@ import { import { NgOptionComponent } from './ng-option.component'; import { NgOptionHighlightDirective } from './ng-option-highlight.directive'; import { NgDropdownPanelComponent } from './ng-dropdown-panel.component'; -import { DefaultSelectionModel } from './selection-model'; +import { DefaultSelectionModelFactory } from './selection-model'; @NgModule({ declarations: [ @@ -54,7 +54,7 @@ import { DefaultSelectionModel } from './selection-model'; NgTagTemplateDirective ], providers: [ - { provide: SELECTION_MODEL_FACTORY, useValue: () => new DefaultSelectionModel() }, + { provide: SELECTION_MODEL_FACTORY, useValue: DefaultSelectionModelFactory }, { provide: NG_SELECT_DEFAULT_CONFIG, useValue: { diff --git a/src/ng-select/selection-model.ts b/src/ng-select/selection-model.ts index f6dd673f1..5bbd2e066 100644 --- a/src/ng-select/selection-model.ts +++ b/src/ng-select/selection-model.ts @@ -2,6 +2,10 @@ import { NgOption } from './ng-select.types'; export type SelectionModelFactory = () => SelectionModel; +export function DefaultSelectionModelFactory() { + return new DefaultSelectionModel(); +} + export interface SelectionModel { value: NgOption[]; select(item: NgOption, multiple: boolean, selectableGroupAsModel: boolean);