本文介绍了Datepicker:无法绑定到"bsValue",因为它不是"input"的已知属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Angular单元测试中,尽管导入了 DatepickerModule.forRoot()
,但我得到了:
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)
推荐答案
错误是我正在导入 DatepickerModule.forRoot()
,但是我需要的是 BsDatepickerModule.forRoot(),
.
The mistake is that I'm importing DatepickerModule.forRoot(),
but instead I need BsDatepickerModule.forRoot(),
.
这是通过以下方式导入的:
This is imported using:
从'ngx-bootstrap'导入{BsDatepickerModule};
这篇关于Datepicker:无法绑定到"bsValue",因为它不是"input"的已知属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!