我得到"p-calendar"不是已知的元素错误,即使在导入日历模块并将其添加到AppModule中的导入之后



即使在导入CalendarModule并将其添加到AppModule 中的导入之后,我也会发现"p-calendar"不是已知的元素错误

浏览器控制台中的实际错误消息

Can't bind to 'ngModel' since it isn't a known property of 'p-calendar'. 1. If 'p-calendar' is an Angular component and it has 'ngModel' input, then verify that it is part of this module. 2. If 'p-calendar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

Dependencies list in my package.json
"dependencies": {
"@angular/animations": "~8.2.14",
"@angular/cdk": "^8.2.3",
"@angular/common": "~8.2.14",
"@angular/compiler": "~8.2.14",
"@angular/core": "~8.2.14",
"@angular/forms": "~8.2.14",
"@angular/platform-browser": "~8.2.14",
"@angular/platform-browser-dynamic": "~8.2.14",
"@angular/router": "~8.2.14",
"bootstrap": "^4.4.1",
"jquery": "^3.5.0",
"primeicons": "^2.0.0",
"primeng": "^9.0.5",
"rxjs": "~6.4.0",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},

您是否也导入了Commonmodule?包含ngModel

我刚刚发现双向绑定需要FormsModule

import { FormsModule } from '@angular/forms';

也将其添加到@NgModule导入

最新更新