How set base config for BsDatepickerModule ?
via using BsDatepickerConfig, such general question better to ask via Stack Overflow
but I made a note about missing sample
https://valor-software.com/ngx-bootstrap/#/datepicker#bs-datepicker-config
How do this for all datepickers in my app?
@valorkin Sorry to ask here, but can't find (noob in angular4) a way to set a global configuration. And the only way I found was using a service and configuring each one with the [bsConfig] input.
Any hint? Thanks for this!
Documentation about this common use case is very limited it seems ...
Just tell the providers to use the config function:
export function getDatepickerConfig(): BsDatepickerConfig {
return Object.assign(new BsDatepickerConfig(), {
containerClass: 'theme-blue',
dateInputFormat: 'DD/MM/YYYY'
});
}
@NgModule({
...
providers: [{ provide: BsDatepickerConfig, useFactory: getDatepickerConfig }]
})
I can't get this to work on a global level in a large app with multiple lazy-loaded modules. It looks like I have to repeat this in every child module, rather than once in the main module. Any work arounds?
@whafrog
gufigueiredo solution works fine with lazy loaded modules. Just add it to app.module.ts (tested on Angular 9, ngx-bootstrap 5.5.0)
Most helpful comment
Just tell the providers to use the config function: