I'm working on an Angular 6 application and I need to create a toggle table with PrimeNG 7.0.5, but I've got this problem when I tried to use <p-table>
:
'p-table' is not a known element
Same problem when I want to use parameters as 'value' in < p-table >.
I am using the Documentation of the TurboTable here.
I have imported the TableModule in my app.module.ts.
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 { }
For the html, I've just tested the code with this:
<p-table></p-table>
I found nothing about this case on the net and on this version... Has somebody has ever had this problem?
import { TableModule } in the module in which component you are using it
First, please make sure you are generating angular and installing primeNG of the compatible version. I also got the same problem before I update my node.js. My node version is now. V12.16.2 and when I install primeNG I got a compatible version. So in part of my package.json is as follows:
"@angular/common": "9.0.4",
"@angular/compiler": "9.0.4",
"@angular/core": "9.0.4",
And the primeNG installed is of the following version:
"primeicons": "^2.0.0",
"primeng": "^9.0.5",
Then, importing the module should be in the nearest module to the html file.
import { TableModule } from 'primeng/table';
Hope it help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With