ngx-bootstrap: BsDatepicker not showing
I used BsDatepickerModule in my application but it is not showing. I followed all the instructions in the documentation but still no luck. I don’t know what’s wrong but I know I properly imported it in my application.
`import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';
@NgModule({
imports: [
BsDatepickerModule.forRoot()`
<label>Date Effective</label> <input type="text" [minDate]="minDate" [maxDate]="maxDate" #dp="bsDatepicker" bsDatepicker>
as well applying the style in angular-cli.json file.
"styles": [ "../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css", "styles.css" ],
I’m in angular 2.3
"dependencies": { "@angular/common": "^2.3.1", "@angular/compiler": "^2.3.1", "@angular/core": "^2.3.1",
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 7
- Comments: 23 (6 by maintainers)
Try to import the BsDatepicker style on the style.scss
@import '../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css';@valorkin in my case i put BsDatepickerModule.forRoot() in global app.module.ts, but then I forgot to import same module inside of child module as well. My mistake.
Btw whoever has issues here is a playground plunkr with proper imports and proper module names: https://plnkr.co/edit/jOqnKkIVNWD63wjSEbuK
you need to import BrowserAnimationsModule to app.module.ts too.
import { BrowserAnimationsModule } from ‘@angular/platform-browser/animations’;
This was related to
z-indexin my case. If the imports are correct, check out the last nodes of the body as the datepicker will be attached there.This is not workaround, this is how angular DI works. Services (providers) have global visibility and should be imported once (forRoot), but components visibly is scoped to module
Why is
BrowserAnimationsModuleeven required? This adds unnecessary bundle size when the app isn’t even using animations.Using ngx-bootstrap is a real pain I feel. There is no clear cut way to add individual components. We have to add the entire library. Now, the
BrowserAnimationsModuleis required even if the app is not using animations. Devs are far better off using something else.I was facing the same issue with angular 8. Please downgrade and restrict your ngx-bootstrap version to 3.0.0