ngx-datatable未在我的component.html

时间:2017-11-10 15:01:18

标签: angular ngx-datatable

我在我的项目中使用角度5.0并尝试使用我也在angular-cli中使用bootstrap css但不是材料

<ngx-datatable
        [rows]="rows"
        [columns]="columns">
      </ngx-datatable>

但在安装和导入模块后,我无法看到我的页面上呈现的网格。

export class AppComponent{

rows = [
    { name: 'Austin', gender: 'Male', company: 'Swimlane' },
    { name: 'Dany', gender: 'Male', company: 'KFC' },
    { name: 'Molly', gender: 'Female', company: 'Burger King' },
  ];
  columns = [
    { prop: 'name' },
    { name: 'Gender' },
    { name: 'Company' }
  ];
}

和module.ts

import { NgxDatatableModule } from '@swimlane/ngx-datatable';

@NgModule({
  imports: [
    BrowserModule,

    NgxDatatableModule
  ],
  declarations: [
    AppComponent
  ],
  providers: [
    {
      provide: HTTP_INTERCEPTORS,
      useClass: APIHeaderInterceptor,
      multi: true,
    },
    SlimLoadingBarService,
    ToastsManager,
    ToasterService,
    ToastOptions

  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  bootstrap: [AppComponent]
})

1 个答案:

答案 0 :(得分:2)

您的prop外壳错误修改如下,

columns = [
        { name: 'Name', prop: 'name' },
        { name: 'Gender', prop : 'gender' },
        { name: 'Company', prop : 'company' }
  ];