Datepicker: can't bind to 'bsValue' since it isn't a known property of 'input'

时间:2018-05-17 14:58:10

标签: javascript angular typescript datepicker ngx-bootstrap

In my Angular unit test, despite I've imported DatepickerModule.forRoot(), I'm getting:

Error: Template parse errors:
    Can't bind to 'bsConfig' since it isn't a known property of 'input'. ("
          class="form-control datepicker datetime-picker"
          bsDatepicker
          [ERROR ->][bsConfig]="myConfig"
          [(ngModel)]="myDate"
        >
    "): ng:///DynamicTestModule/DatetimePickerComponent.html@6:6
        at syntaxError node_modules/@angular/compiler/esm5/compiler.js:486:22)
        at TemplateParser.webpackJsonp../node_modules/@angular/compiler/esm5/compiler.js.TemplateParser.parse node_modules/@angular/compiler/esm5/compiler.js:24674:1)
        at JitCompiler.webpackJsonp../node_modules/@angular/compiler/esm5/compiler.js.JitCompiler._parseTemplate node_modules/@angular/compiler/esm5/compiler.js:34629:1)
        at JitCompiler.webpackJsonp../node_modules/@angular/compiler/esm5/compiler.js.JitCompiler._compileTemplate node_modules/@angular/compiler/esm5/compiler.js:34604:1)
        at http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/compiler/esm5/compiler.js:34505:48
        at Set.forEach (<anonymous>)
        at JitCompiler.webpackJsonp../node_modules/@angular/compiler/esm5/compiler.js.JitCompiler._compileComponents node_modules/@angular/compiler/esm5/compiler.js:34505:1)
        at http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/compiler/esm5/compiler.js:34393:1
        at Object.then node_modules/@angular/compiler/esm5/compiler.js:475:33)
        at JitCompiler.webpackJsonp../node_modules/@angular/compiler/esm5/compiler.js.JitCompiler._compileModuleAndAllComponents node_modules/@angular/compiler/esm5/compiler.js:34391:1)
    Expected undefined to be truthy.
        at UserContext.<anonymous> src/app/components/my-spec.spec.ts:41:23)
        at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke node_modules/zone.js/dist/zone.js:388:1)
        at ProxyZoneSpec.webpackJsonp../node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke node_modules/zone.js/dist/proxy.js:128:1)

1 个答案:

答案 0 :(得分:2)

The mistake is that I'm importing DatepickerModule.forRoot(), but instead I need BsDatepickerModule.forRoot(),.

This is imported using:

import { BsDatepickerModule } from 'ngx-bootstrap';