angular - 即使导入 CalendarModule 后,“p-calendar”也不是已知元素错误

标签 angular primeng

即使在导入 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>

Calendar error

最佳答案

看来您错过了导入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/

相关文章:

angular - PrimeNG DataTable 过滤 filterMatchType 不是默认值

Angular 2 订阅/取消订阅 http 调用时的 Observables

javascript - Angular :无法获取/

angular - 如何在 Angular 中创建一个简单的主机组件?

angular - 在 primeng pcalendar 中设置空白值

angular - PrimeNG 数据表未以 Angular 2 显示

angular - 分层注入(inject)器和依赖生命周期

javascript - 在发布请求时设置标题 - Angular

angular - Prime NG 的可编辑表格上的奇怪行为

PrimeNG:DynamicDialog 的自定义 header