0

我只是想在我的 Angular 4 项目中实现 PrimeNG 库。我可以在我的依赖项和我的 nodemodules 文件夹中看到 PrimeNG,但是当我做了一个简单的操作时:

        <p-dataTable >
           <p-column ></p-column>
           <p-column ></p-column>
           <p-column ></p-column>
           <p-column ></p-column>
       </p-dataTable>

这是我控制台浏览器中的错误:

Unhandled Promise rejection: Template parse errors:
'p-column' is not a known element:
1. If 'p-column' is an Angular component, then verify that it is part of this module.
2. If 'p-column' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("

        <p-dataTable >
       [ERROR ->]<p-column ></p-column>
       <p-column ></p-column>
       <p-column ></p-column>
       "): ng:///AppModule/TableaudebordComponent.html@5:4

这是我的 app.module.ts:

import { TableaudebordComponent } from './tableaudebord.component';
import { RouterModule, Routes } from '@angular/router'
import { ToggleComponent }  from './toggle.component';
import { HttpModule } from '@angular/http';
import { routeConfig } from './router-config';
import { AppComponent }  from './app.component';
import { UserService } from './user.service'; //  <-- #1 import  service

@NgModule({
 imports:      [ BrowserModule, HttpModule,     RouterModule.forRoot(routeConfig)
 ],
 declarations: [ AppComponent, DashboardComponent,          PageNotFoundComponent, NavbarComponent,PetitPaveInfraComponent,   PaveInfraComponent, PetitPaveAppliComponent, DashboardnextComponent, Dashboardnext2Component, Dashboardnext3Component,  PetitPaveProblemComponent, PaveProblemComponent, ToggleComponent,   TableaudebordComponent ],
providers: [ UserService ], 
bootstrap:    [ AppComponent ]
})
export class AppModule { }
4

1 回答 1

0

确保导入您想要使用的任何 PrimeNG 组件所需的模块。在这种情况下,您希望在导入模块后将DataTableModule&添加SharedModuleimports您的数组中,app.module.ts例如 from primeng:

import {DataTableModule,SharedModule} from 'primeng/primeng';

imports: [..., DataTableModule, SharedModule]

于 2017-05-22T16:13:47.293 回答