即使在导入 CalendarModule 后,在 angular2 中使用 p-calendar 时也会出现以下错误。
从“../../../vendor/primeng/components/calendar/calendar”导入{CalendarModule};
Uncaught Error: Template parse errors:
'p-calendar' is not a known element:
1. If 'p-calendar' is an Angular component, 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. ("
<div>
Calendar
[ERROR ->]<p-calendar [(ngModel)]="todaysDate"></p-calendar>
</div>
最佳答案
看来您错过了导入CalendarModule
在您的应用程序内。您必须导入 CalendarModule
在你的AppModule
里面来自primeng
库并将其注入(inject)到您的 imports
中的AppModule
.
import {CalendarModule} from 'primeng/calendar';
@NgModule({
imports: [
BrowserModule,
FormsModule,
CalendarModule, //<-- injected module here.
FormsModule
],
declarations: [ ... ],
bootstrap: [ ... ]
})
export class AppModule { }
关于angular - 即使导入 CalendarModule 后,“p-calendar”也不是已知元素错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51577896/