Angular 底漆:和#x27;p-表';不是已知元素

Angular 底漆:和#x27;p-表';不是已知元素,angular,typescript,primeng,Angular,Typescript,Primeng,我正在开发Angular 6应用程序,需要使用Priming 7.0.5创建一个切换表,但在尝试使用时遇到了这个问题: “p-table”不是已知元素 当我想在中使用参数作为“值”时,也会出现同样的问题 我正在使用TurboTable的文档 我已在app.module.ts中导入TableModule app.module.ts import { CommonModule, registerLocaleData } from '@angular/common'; import { HttpCli

我正在开发Angular 6应用程序,需要使用Priming 7.0.5创建一个切换表,但在尝试使用
时遇到了这个问题:

“p-table”不是已知元素

当我想在中使用参数作为“值”时,也会出现同样的问题

我正在使用TurboTable的文档

我已在app.module.ts中导入TableModule

app.module.ts

import { CommonModule, registerLocaleData } from '@angular/common';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { HttpModule } from '@angular/http';
import { NgModule, Pipe, PipeTransform, LOCALE_ID } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AuthGuard } from './shared';
import { FormsModule } from '@angular/forms';
import { MessageComponent } from './message/message.component';
import { MessageService } from './message/message.service';
// imported it here
import { TableModule } from 'primeng/table';
import localeFr from '@angular/common/locales/fr';

registerLocaleData(localeFr);

export const createTranslateLoader = (http: HttpClient) => {
    return new TranslateHttpLoader(http, './assets/i18n/', '.json');
};

@NgModule({
    imports: [
        CommonModule,
        BrowserModule,
        BrowserAnimationsModule,
        HttpClientModule,
        FormsModule,
        HttpModule,
        TableModule,    /* <-- added this */
        TranslateModule.forRoot({
            loader: {
                provide: TranslateLoader,
                useFactory: createTranslateLoader,
                deps: [HttpClient]

            }
        }),
        AppRoutingModule
    ],
    declarations: [AppComponent, MessageComponent],
    providers: [AuthGuard, MessageService, { provide: LOCALE_ID, useValue: 'fr-FR' }],
    bootstrap: [AppComponent]
})
export class AppModule { }
从'@angular/common'导入{CommonModule,registerLocaleData};
从“@angular/common/http”导入{HttpClient,HttpClientModule};
从'@angular/http'导入{HttpModule};
从'@angular/core'导入{NgModule,Pipe,PipeTransform,LOCALE_ID};
从“@angular/platform browser”导入{BrowserModule};
从“@angular/platform browser/animations”导入{BrowserAnimationsModule};
从'@ngx translate/core'导入{TranslateLoader,TranslateModule};
从'@ngx translate/http loader'导入{TranslateHttpLoader};
从“./app routing.module”导入{AppRoutingModule};
从“./app.component”导入{AppComponent};
从“./shared”导入{AuthGuard};
从'@angular/forms'导入{FormsModule};
从“./message/message.component”导入{MessageComponent};
从“./message/message.service”导入{MessageService};
//从这里进口的
从'priming/table'导入{TableModule};
从“@angular/common/locales/fr”导入localeFr;
寄存器本地数据(localeFr);
export const createTranslateLoader=(http:HttpClient)=>{
返回新的TranslateHttpLoader(http,“./assets/i18n/”,“.json”);
};
@NGD模块({
进口:[
公共模块,
浏览器模块,
BrowserAnimationsModule,
HttpClientModule,
FormsModule,
HttpModule,

TableModule,/*导入{TableModule}在您使用它的组件所在的模块中

首先,请确保您正在生成兼容版本的angular并安装Priming。在更新node.js之前,我也遇到了同样的问题。我的节点版本现在是.V12.16.2,安装Priming时,我得到了兼容版本。 因此,mypackage.json的一部分如下所示:

"@angular/common": "9.0.4",
"@angular/compiler": "9.0.4",
"@angular/core": "9.0.4",
所安装的底漆为以下版本:

"primeicons": "^2.0.0",
"primeng": "^9.0.5",
然后,导入模块应位于距离html文件最近的模块中

import { TableModule } from 'primeng/table';

希望有帮助。

代码中没有空格,我刚把它放到帖子中,因为p-table消失了,没有空格:/就是因为,我没有将模块导入到好的文件中。谢谢!我不确定你做错了什么。请检查此工作,将其导入到组件类所属的模块中。我验证,我刚刚声明了它在AppModule中
import { TableModule } from 'primeng/table';