关于 Angular 8 中的 PrimeNg 表

Aas*_*hiq 1 html typescript angular-material primeng angular

我尝试在我的 Angular 应用程序中使用 p-table(PrimeNg table),我从 CLI 导入了所有必要的依赖项和模块文件中的导入,错误是,

目标入口点“primeng/table”中的错误缺少依赖项:-@angular/cdk/scrolling

    import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AccordionModule } from 'primeng/accordion'; //accordion and accordion tab
import { MenuItem } from 'primeng/api';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { TableModule } from 'primeng/table';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, AppRoutingModule, AccordionModule,TableModule],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}
Run Code Online (Sandbox Code Playgroud)

我的 component.html 是:

<h1>Hello {{ title }}</h1>
<br />

<p-table [value]="detail">
  <ng-template pTemplate="header">
    <tr>
      <th>Vin</th>
      <th>Year</th>
      <th>Brand</th>
      <th>Color</th>
    </tr>
  </ng-template>
  <ng-template pTemplate="body" let-car>
    <tr>
      <td>Aashiq</td>
      <td>Aadhil</td>
      <td>Zubair</td>
      <td>Athaa</td>
    </tr>
  </ng-template>
</p-table>
Run Code Online (Sandbox Code Playgroud)

我的 app.component.ts 是:

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


@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  ngOnInit(): void {

    throw new Error("Method not implemented.");
  }
  title = 'Angularprimeng';
    detail:any;

}


Run Code Online (Sandbox Code Playgroud)

小智 5

晚上好!

您是否尝试过安装材料cdk?

npm install @angular/cdk --save
Run Code Online (Sandbox Code Playgroud)

这应该可以解决您的问题。

问候,

乔纳森