Created
March 9, 2020 15:45
-
-
Save Hagith/d77bdeb4605ba412ac996d39ba3479c9 to your computer and use it in GitHub Desktop.
include only used ngx-bootstrap components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Import only used ngx-bootstrap components. | |
* | |
* @see https://valor-software.com/ngx-bootstrap/#/getting-started | |
*/ | |
import { Injectable, NgModule } from '@angular/core'; | |
import { | |
AlertModule, | |
BsDatepickerConfig, | |
BsDatepickerModule, | |
BsDaterangepickerConfig, | |
BsLocaleService, | |
CollapseModule, | |
ModalModule, | |
TabsModule, | |
} from 'ngx-bootstrap'; | |
const datepickerDefaults: Partial<BsDatepickerConfig> = { | |
containerClass: 'theme-default', | |
isAnimated: true, | |
displayMonths: 1, | |
}; | |
// overwrite BsLocaleService to be provided for 'root' injector (force single instance) | |
@Injectable({ providedIn: 'root' }) | |
export class NgxBootstrapLocaleService extends BsLocaleService {} | |
@NgModule({ | |
imports: [ | |
// AccordionModule.forRoot(), | |
AlertModule.forRoot(), | |
BsDatepickerModule.forRoot(), | |
// ButtonsModule.forRoot(), | |
// CarouselModule.forRoot(), | |
CollapseModule.forRoot(), | |
ModalModule.forRoot(), | |
// PaginationModule.forRoot(), | |
// PopoverModule.forRoot(), | |
// ProgressbarModule.forRoot(), | |
// RatingModule.forRoot(), | |
// SortableModule.forRoot(), | |
TabsModule.forRoot(), | |
// TimepickerModule.forRoot(), | |
// TooltipModule.forRoot(), | |
// TypeaheadModule.forRoot(), | |
], | |
exports: [ | |
// AccordionModule, | |
AlertModule, | |
BsDatepickerModule, | |
// ButtonsModule, | |
// CarouselModule, | |
CollapseModule, | |
ModalModule, | |
// PaginationModule, | |
// PopoverModule, | |
// ProgressbarModule, | |
// RatingModule, | |
// SortableModule, | |
TabsModule, | |
// TimepickerModule, | |
// TooltipModule, | |
// TypeaheadModule, | |
], | |
providers: [ | |
{ | |
provide: BsDatepickerConfig, | |
useFactory: () => { | |
const config = new BsDatepickerConfig(); | |
return Object.assign(config, datepickerDefaults); | |
}, | |
}, | |
{ | |
provide: BsDaterangepickerConfig, | |
useFactory: () => { | |
const config = new BsDaterangepickerConfig(); | |
return Object.assign(config, datepickerDefaults); | |
}, | |
}, | |
{ | |
provide: BsLocaleService, | |
useExisting: NgxBootstrapLocaleService, | |
}, | |
], | |
}) | |
export class NgxBootstrapModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment