Search code examples
angularprimengprimeng-table

Error while using primeng table with angular 7


I am trying to use primeng-table with angular7. But after integrating it I am getting the below error:-

Uncaught TypeError: Object(...) is not a function at platform.es5.js:102 at Module../node_modules/@angular/cdk/esm5/platform.es5.js (platform.es5.js:104) at webpack_require (bootstrap:78) at Module../node_modules/@angular/cdk/esm5/scrolling.es5.js (scrolling.es5.js:1) at webpack_require (bootstrap:78) at Object../node_modules/primeng/components/dropdown/dropdown.js (dropdown.js:12) at webpack_require (bootstrap:78) at Object../node_modules/primeng/components/paginator/paginator.js (paginator.js:15) at webpack_require (bootstrap:78) at Object../node_modules/primeng/components/datagrid/datagrid.js (datagrid.js:15)

html file

<html>
<div class="courses">
  <h1>This is the Courses Page!</h1>
  <br><br><br><br>
  </div>
<p-dataTable [value]="courses">
  <p-column field="id" header="id"></p-column>
  <p-column field="name" header="name"></p-column>
</p-dataTable>
</html>

Component File

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-courses',
 templateUrl: './courses.component.html',
  styleUrls: ['./courses.component.less']
})
export class CoursesComponent implements OnInit {
  courses: any[];
  constructor() { }
  ngOnInit() {
    this.courses = [
      { id: '1', name: 'Course1' },
      { id: '2', name: 'Course2' },
      { id: '3', name: 'Course3' }
    ];
  }
}

You can find the entire code here - Code

Can anyone please tell me where I am doing wrong?

Thanks!


Solution

  • Hi Please update dependencies and used p-table from TableModule, its working fine, check the package json. Here is stackblitz Hope it helps !

    enter image description here