在我的Angular单元测试中,尽管我已导入DatepickerModule.forRoot()
,但我得到了:
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)
最佳答案
错误是我正在导入DatepickerModule.forRoot(),
,但是我需要BsDatepickerModule.forRoot(),
。
使用以下命令导入:import { BsDatepickerModule } from 'ngx-bootstrap';
关于javascript - Datepicker:无法绑定(bind)到 'bsValue',因为它不是 'input'的已知属性,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50394597/