Ngx-bootstrap: [Datepicker]Can't bind to 'bsValue' since it isn't a known property of 'input'.

Created on 28 Aug 2017  路  18Comments  路  Source: valor-software/ngx-bootstrap

when i use datepicker, i have this error
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import {NavbarComponent} from './navbar/navbar.component';
import {DatepickerModule} from "ngx-bootstrap";
import {FormsModule} from "@angular/forms";

@NgModule({
declarations: [
AppComponent,
NavbarComponent
],
imports: [
BrowserModule,
DatepickerModule.forRoot(),
FormsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

value="{{ bsValue | date:'yMd'}}"
bsDatepicker `[(bsValue)]="bsValue">]

public bsValue: any ;

Most helpful comment

I have this on .angular-cli.json

"styles": [
    "../node_modules/bootstrap/dist/css/bootstrap.css",
    "../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
    "styles.scss"
],

All 18 comments

having the same error

Pay attention to docs, you need to import BsDatepickerModule.forRoot()

image

?

http://valor-software.com/ngx-bootstrap/#/datepicker#examples
BsDatepickerModule is activily developed but you can use it already

when i include BsDatepickerModule, the datepicker shows,but it has none css,like this
image
how can i include the bs-datepicker.css

@BluesPeter If you are using angular cli, insert the css path on styles section inside .angular-cli.json file.

How did you get the datepicker working? I am just getting errors:

import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';

@NgModule({
  imports: [BsDatepickerModule.forRoot(),...]
})
export class AppModule(){}

<input type="text"
       value="{{ bsValue | date:'yMd'}}"
       bsDatepicker [(bsValue)]="bsValue">

- - - - - - - - - -

ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'bsValue' since it isn't a known property of 'input'. ("type="text"
                     value="{{ bsValue | date:'yMd'}}"
                     bsDatepicker [ERROR ->][(bsValue)]="bsValue">

@Hesesses which version ngx-bootstrap do you use, you must use version 1.9.1,and you must also
imports DatepickerModule.forRoot()

@BluesPeter i'm using 1.9.1 and I have tried to import both together and separately, but nothing seems to work =/

Update
Got it working, I had forgot to export it on my shared module 馃檲

I will add this to FAQ one day
90% issue like this:

  • forgot to import
  • forgot forRoot
  • forgot to import in child\lazy module
  • forgot to export from shared module
    :)

@BluesPeter how did you include the bs-datepicker.css ?? I'm having the same problem

same here. where to load those missing class

<bs-datepicker-view ng-reflect-months="[object Object]" ng-reflect-options="[object Object]"> <div class="bs-datepicker bs-timepicker theme-green"> <div class="bs-datepicker-head">

bs-datepicker.css should be included same way you include bootstrap.css

i still don't see how :( i added "/datepicker/bs-datepicker.css" to .angular-cli.json like @Hesesses mentioned ( because i'm using angular-cli )
1
but i didn't add any styleUrl in the component that i'm using
2
should i add a styleUrl ??

I have this on .angular-cli.json

"styles": [
    "../node_modules/bootstrap/dist/css/bootstrap.css",
    "../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
    "styles.scss"
],

image
@EyaRhouma
I use like this,and i have solved this problem

@Hesesses @BluesPeter thannnks so much 馃拑 the path "../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css" worked for me

@Hesesses @BluesPeter thanks! :)

Angular 6:

step 1: npm install ngx-bootstrap@4 --save
step 2: In ./src/styles.css
@import '~bootstrap/dist/css/bootstrap.min.css';
@import '~open-iconic/font/css/open-iconic-bootstrap.css';
step 3: in app.module.ts
import { BsDatepickerModule } from 'ngx-bootstrap'; and addit to imports array
@NgModule({
declarations: [ ],
imports: [
BsDatepickerModule.forRoot()
]

Was this page helpful?
0 / 5 - 0 ratings